diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-08-01 08:17:50 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-08-01 08:17:50 +0100 |
commit | cef6e7833c6ec89363c982ccf86e1ec5921db1dc (patch) | |
tree | 857c5c661ba3e9789959547232f48c9720d058c9 /src/plugins | |
parent | 634582d5d00ca0b15eb533fd4cde468120430ab6 (diff) | |
download | rspamd-cef6e7833c6ec89363c982ccf86e1ec5921db1dc.tar.gz rspamd-cef6e7833c6ec89363c982ccf86e1ec5921db1dc.zip |
[Feature] Implement per-user ANN support
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/fann_redis.lua | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/plugins/lua/fann_redis.lua b/src/plugins/lua/fann_redis.lua index 2ae9c19d8..6a7a73cdd 100644 --- a/src/plugins/lua/fann_redis.lua +++ b/src/plugins/lua/fann_redis.lua @@ -35,6 +35,7 @@ local default_options = { max_epoch = 1000, max_usages = 10, use_settings = false, + per_user = false, watch_interval = 60.0, mse = 0.001, autotrain = true, @@ -336,6 +337,10 @@ local function fann_scores_filter(task) id = rule.prefix .. tostring(sid) end end + if rule.per_user then + local r = task:get_principal_recipient() + id = id .. r + end if fanns[id].fann then local fann_data = task:get_symbols_tokens() @@ -881,14 +886,17 @@ end local function ann_push_vector(task) local scores = task:get_metric_score() - local sid = task:get_settings_id() for _,rule in ipairs(settings.rules) do + local sid = "0" if rule.use_settings then - fann_train_callback(rule, task, scores[1], scores[2], tostring(sid)) - else - fann_train_callback(rule, task, scores[1], scores[2], "0") + sid = tostring(task:get_settings_id()) + end + if rule.per_user then + local r = task:get_principal_recipient() + sid = sid .. r end + fann_train_callback(rule, task, scores[1], scores[2], sid) end end |