commit ae0ea5d: [Minor] Selectors: Add inverse processor

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Dec 27 18:28:06 UTC 2018


Author: Vsevolod Stakhov
Date: 2018-12-11 19:47:45 +0000
URL: https://github.com/rspamd/rspamd/commit/ae0ea5dee527e161142eb889312fe7bf4558c88a

[Minor] Selectors: Add inverse processor

---
 lualib/lua_selectors.lua | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua
index 4025ef680..ab2692eac 100644
--- a/lualib/lua_selectors.lua
+++ b/lualib/lua_selectors.lua
@@ -524,6 +524,22 @@ Returns either nil or its input if input is in args list]],
 Returns either nil or its input if input is not in args list]],
     ['args_schema'] = ts.array_of(ts.string)
   },
+  ['inverse'] = {
+    ['types'] = {
+      ['string'] = true,
+    },
+    ['map_type'] = 'string',
+    ['process'] = function(inp, _, args)
+      if inp then
+        return nil
+      else
+        return (args[1] or 'true'),'string'
+      end
+    end,
+    ['description'] = [[Inverses input.
+Empty string comes the first argument or 'true', non-empty string comes nil]],
+    ['args_schema'] = {ts.string:is_optional()}
+  },
 }
 
 local function process_selector(task, sel)


More information about the Commits mailing list