aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/rspamd_update.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-10 16:55:52 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-10 16:55:52 +0000
commitac0307f4de186629bcbc58582f0207825fe56740 (patch)
tree0282d4998c74322f3a586a5f8b6fd29ce5473d0d /src/plugins/lua/rspamd_update.lua
parentc05ec57c6a8745d2fe56a691e931b86ba9276594 (diff)
downloadrspamd-ac0307f4de186629bcbc58582f0207825fe56740.tar.gz
rspamd-ac0307f4de186629bcbc58582f0207825fe56740.zip
[Feature] Allow priorities in dynamic updates
Diffstat (limited to 'src/plugins/lua/rspamd_update.lua')
-rw-r--r--src/plugins/lua/rspamd_update.lua19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/plugins/lua/rspamd_update.lua b/src/plugins/lua/rspamd_update.lua
index 344f58ebe..25898d712 100644
--- a/src/plugins/lua/rspamd_update.lua
+++ b/src/plugins/lua/rspamd_update.lua
@@ -25,22 +25,22 @@ local hash = require "rspamd_cryptobox_hash"
local rspamd_version = rspamd_version
local maps = {}
-local function process_symbols(obj)
+local function process_symbols(obj, priority)
each(function(sym, score)
rspamd_config:set_metric_symbol({
name = sym,
score = score,
- priority = updates_priority
+ priority = priority
})
end, obj)
end
-local function process_actions(obj)
+local function process_actions(obj, priority)
each(function(act, score)
rspamd_config:set_metric_action({
action = act,
score = score,
- priority = updates_priority
+ priority = priority
})
end, obj)
end
@@ -59,6 +59,10 @@ end
local function check_version(obj)
local ret = true
+ if not obj then
+ return false
+ end
+
if obj['min_version'] then
if rspamd_version('cmp', obj['min_version']) > 0 then
ret = false
@@ -92,6 +96,13 @@ local function gen_callback(map)
local obj = parser:get_object()
if check_version(obj) then
+
+ local priority = updates_priority
+
+ if obj['priority'] then
+ priority = obj['priority']
+ end
+
if obj['symbols'] then
process_symbols(obj['symbols'])
end