]> source.dussan.org Git - rspamd.git/commitdiff
[Rework] Dkim_signing: Move sign condition to dkim_signing
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 31 May 2019 15:16:38 +0000 (16:16 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 31 May 2019 15:16:38 +0000 (16:16 +0100)
lualib/lua_dkim_tools.lua

index 5026bbd6be0d5f43f3bf932ace6b805fa9fa1aba..fbb071245f4b48a3029dc41b853d826e724bb42a 100644 (file)
@@ -134,6 +134,17 @@ local function prepare_dkim_signing(N, task, settings)
     end
   end
 
+  if settings.sign_condition and type(settings.sign_condition) == 'function' then
+    -- Use sign condition only
+    local ret = settings.sign_condition(task)
+
+    if not ret then
+      return false,{}
+    end
+
+    return true,ret
+  end
+
   local auser = task:get_user()
   local ip = task:get_from_ip()
 
@@ -673,6 +684,8 @@ exports.process_signing_settings = function(N, settings, opts)
       settings[k] = lua_maps.map_add(N, k, 'glob', 'DKIM keys table')
     elseif k == 'vault_domains' then
       settings[k] = lua_maps.map_add(N, k, 'glob', 'DKIM signing domains in vault')
+    elseif k == 'sign_condition' then
+      settings[k] = lua_util.callback_from_string(v)
     else
       settings[k] = v
     end