]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow priorities in dynamic updates
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 10 Mar 2016 16:55:52 +0000 (16:55 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 10 Mar 2016 16:55:52 +0000 (16:55 +0000)
src/plugins/lua/rspamd_update.lua

index 344f58ebee5a65098a7bcbfd68475b8c5d25cd09..25898d712d1ccd1eb318d1f6eadd33b8e5c5c177 100644 (file)
@@ -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