#define RSPAMD_TASK_FLAG_LEARN_HAM (1 << 17)
#define RSPAMD_TASK_FLAG_LEARN_AUTO (1 << 18)
#define RSPAMD_TASK_FLAG_BROKEN_HEADERS (1 << 19)
+#define RSPAMD_TASK_FLAG_HAS_SPAM_TOKENS (1 << 20)
+#define RSPAMD_TASK_FLAG_HAS_HAM_TOKENS (1 << 21)
#define RSPAMD_TASK_IS_SKIPPED(task) (((task)->flags & RSPAMD_TASK_FLAG_SKIP))
#define RSPAMD_TASK_IS_JSON(task) (((task)->flags & RSPAMD_TASK_FLAG_JSON))
tok->values[id] = rspamd_mmaped_file_get_block (mf, h1, h2);
}
+ if (mf->cf->is_spam) {
+ task->flags |= RSPAMD_TASK_FLAG_HAS_SPAM_TOKENS;
+ }
+ else {
+ task->flags |= RSPAMD_TASK_FLAG_HAS_HAM_TOKENS;
+ }
+
return TRUE;
}
processed ++;
}
+
+ if (rt->stcf->is_spam) {
+ task->flags |= RSPAMD_TASK_FLAG_HAS_SPAM_TOKENS;
+ }
+ else {
+ task->flags |= RSPAMD_TASK_FLAG_HAS_HAM_TOKENS;
+ }
+ }
+ else {
+ msg_err_task ("got invalid length of reply vector from redis: "
+ "%d, expected: %d",
+ (gint)reply->elements,
+ (gint)task->tokens->len);
}
}
else {
+ msg_err_task ("got invalid reply from redis: %d",
+ reply->type);
}
msg_debug_task ("received tokens for %s: %d processed, %d found",
else {
tok->values[id] = 0.0;
}
+
+ if (rt->cf->is_spam) {
+ task->flags |= RSPAMD_TASK_FLAG_HAS_SPAM_TOKENS;
+ }
+ else {
+ task->flags |= RSPAMD_TASK_FLAG_HAS_HAM_TOKENS;
+ }
}
guint i;
struct rspamd_classifier *cl;
+ if (st_ctx->classifiers->len == 0) {
+ return;
+ }
+
+ /*
+ * Do not classify a message if some class is missing
+ */
+ if (!(task->flags & RSPAMD_TASK_FLAG_HAS_SPAM_TOKENS)) {
+ msg_warn_task ("skip statistics as SPAM class is missing");
+
+ return;
+ }
+ if (!(task->flags & RSPAMD_TASK_FLAG_HAS_HAM_TOKENS)) {
+ msg_warn_task ("skip statistics as HAM class is missing");
+
+ return;
+ }
+
for (i = 0; i < st_ctx->classifiers->len; i++) {
cl = g_ptr_array_index (st_ctx->classifiers, i);
g_assert (cl != NULL);