aboutsummaryrefslogtreecommitdiffstats
path: root/src/controller.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-23 18:36:41 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-23 18:36:41 +0000
commit3280d0a385cc84c4f2b44a556c26a73291d59820 (patch)
tree7354c0d009e8df9166aa7d379c4ff03fcf1569a0 /src/controller.c
parent171031923755ae89ed2672130b3fb3665c5c8796 (diff)
downloadrspamd-3280d0a385cc84c4f2b44a556c26a73291d59820.tar.gz
rspamd-3280d0a385cc84c4f2b44a556c26a73291d59820.zip
Restore multiple classifiers support
Diffstat (limited to 'src/controller.c')
-rw-r--r--src/controller.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/controller.c b/src/controller.c
index c0783ce9d..bb494108f 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -1168,7 +1168,7 @@ rspamd_controller_learn_fin_task (void *ud)
conn_ent = task->fin_arg;
session = conn_ent->ud;
- if (rspamd_learn_task_spam (session->cl, task, session->is_spam, &err) ==
+ if (rspamd_learn_task_spam (task, session->is_spam, session->classifier, &err) ==
RSPAMD_STAT_PROCESS_ERROR) {
msg_info_session ("cannot learn <%s>: %e", task->message_id, err);
rspamd_controller_send_error (conn_ent, err->code, err->message);
@@ -1238,8 +1238,8 @@ rspamd_controller_handle_learn_common (
{
struct rspamd_controller_session *session = conn_ent->ud;
struct rspamd_controller_worker_ctx *ctx;
- struct rspamd_classifier_config *cl;
struct rspamd_task *task;
+ const rspamd_ftok_t *cl_header;
ctx = session->ctx;
@@ -1255,13 +1255,6 @@ rspamd_controller_handle_learn_common (
return 0;
}
- /* XXX: now work with only bayes */
- cl = rspamd_config_find_classifier (ctx->cfg, "bayes");
- if (cl == NULL) {
- rspamd_controller_send_error (conn_ent, 400, "Classifier not found");
- return 0;
- }
-
task = rspamd_task_new (session->ctx->worker, session->cfg);
task->resolver = ctx->resolver;
@@ -1277,8 +1270,14 @@ rspamd_controller_handle_learn_common (
task->http_conn = rspamd_http_connection_ref (conn_ent->conn);;
task->sock = -1;
session->task = task;
- session->cl = cl;
+ cl_header = rspamd_http_message_find_header (msg, "classifier");
+ if (cl_header) {
+ session->classifier = rspamd_mempool_ftokdup (session->pool, cl_header);
+ }
+ else {
+ session->classifier = NULL;
+ }
if (!rspamd_task_load_message (task, msg, msg->body_buf.begin, msg->body_buf.len)) {
rspamd_controller_send_error (conn_ent, task->err->code, task->err->message);