]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Settings: Fix selectors usage
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 11 Dec 2018 19:43:10 +0000 (19:43 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 11 Dec 2018 19:43:10 +0000 (19:43 +0000)
src/plugins/lua/settings.lua

index 970062d3b71cc0f0a4dae076820c1383fb346cb1..7ad85d184f0a8f13919740deadd39d1146db5476 100644 (file)
@@ -316,22 +316,8 @@ local function check_settings(task)
       end
     end
 
-    if rule['selector'] then
-      local sel = selectors_cache[rule_name]
-      if not sel then
-        sel = lua_selectors.create_selector_closure(rspamd_config, rule.selector,
-            rule.delimiter or "")
-
-        if sel then
-          selectors_cache[rule_name] = sel
-        end
-      end
-
-      if sel then
-        if sel(task) then
-          res = true
-        end
-      end
+    if rule.selector then
+      res = rule.selector(task)
     end
 
     if res then
@@ -602,6 +588,22 @@ local function process_settings_table(tbl)
       end
     end
 
+    if elt['selector'] then
+      local sel = selectors_cache[name]
+      if not sel then
+        sel = lua_selectors.create_selector_closure(rspamd_config, elt.selector,
+            elt.delimiter or "")
+
+        if sel then
+          selectors_cache[name] = sel
+        end
+      end
+
+      if sel then
+        out['selector'] = sel
+      end
+    end
+
     -- Now we must process actions
     if elt['symbols'] then out['symbols'] = elt['symbols'] end
     if elt['id'] then