]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Feature] Allow to add symbols using settings directly
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 12 Jun 2018 12:52:40 +0000 (13:52 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 12 Jun 2018 12:52:40 +0000 (13:52 +0100)
src/plugins/lua/settings.lua

index 8e4009162b73d4701258cc3852c766d360b3742b..468ab6583a2146c2002a74807e14c09d44318adb 100644 (file)
@@ -55,6 +55,24 @@ local function apply_settings(task, to_apply)
       task:set_flag(fl)
     end
   end
+
+  if to_apply.symbols then
+    -- Add symbols, specified in the settings
+    if #to_apply.symbols > 0 then
+      fun.each(function(val)
+        task:insert_result(val, 1.0)
+      end,
+          fun.filter(function(elt) return type(elt) == 'string' end,
+              to_apply.symbols))
+    else
+      -- Object like symbols
+      fun.each(function(k, val)
+        task:insert_result(k, val.score or 1.0, val.options or {})
+      end,
+          fun.filter(function(_, elt) return type(elt) == 'table' end,
+              to_apply.symbols))
+    end
+  end
 end
 
 -- Checks for overridden settings within query params and returns 'true' if