From ef6ed76aa67ada4dc45b0b0bccb437b22d56a2ab Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 22 Mar 2016 13:49:10 +0000 Subject: [Feature] Do not classify message if some class is missing --- src/libstat/stat_process.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/libstat/stat_process.c') diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 6b1b16aed..1761dc7a3 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -321,6 +321,24 @@ rspamd_stat_classifiers_process (struct rspamd_stat_ctx *st_ctx, 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); -- cgit v1.2.3