]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add method create_selector_closure
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 15 Sep 2018 12:15:48 +0000 (13:15 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 15 Sep 2018 12:15:48 +0000 (13:15 +0100)
lualib/lua_selectors.lua

index cef2d163f54c1c32b864d832232e1f904fe44b4b..06e23fc80e3dcb77575ce23a8a79cc52391e3b58 100644 (file)
@@ -702,6 +702,27 @@ exports.combine_selectors = function(_, selectors, delimiter)
   end
 end
 
+--[[[
+-- @function lua_selectors.create_closure(cfg, selector_str, delimiter='')
+--]]
+exports.create_selector_closure = function(cfg, selector_str, delimiter)
+  local selector = exports.parse_selector(cfg, selector_str)
+
+  if not selector then
+    return nil
+  end
+
+  return function(task)
+    local res = exports.process_selectors(task, selector)
+
+    if res then
+      return exports.combine_selectors(_, res, delimiter)
+    end
+
+    return nil
+  end
+end
+
 local function display_selectors(tbl)
   return fun.tomap(fun.map(function(k,v)
     return k, fun.tomap(fun.filter(function(kk, vv)