From: Vsevolod Stakhov Date: Tue, 21 Aug 2018 11:39:33 +0000 (+0100) Subject: [Minor] Add `in` and `not_in` transformations X-Git-Tag: 1.8.0~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa95595931bf1ad08c1ee20f144074e31222acd8;p=thirdparty%2Frspamd.git [Minor] Add `in` and `not_in` transformations --- diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua index 69a20b9c49..5f2f3564ad 100644 --- a/lualib/lua_selectors.lua +++ b/lualib/lua_selectors.lua @@ -382,6 +382,27 @@ local transform_function = { return inp[args[1]](inp) end }, + -- Boolean function in, returns either nil or its input if input is in args list + ['in'] = { + ['types'] = { + ['string'] = true, + }, + ['map_type'] = 'string', + ['process'] = function(inp, _, args) + for _,a in ipairs(args) do if a == inp then return inp end end + return nil + end + }, + ['not_in'] = { + ['types'] = { + ['string'] = true, + }, + ['map_type'] = 'string', + ['process'] = function(inp, _, args) + for _,a in ipairs(args) do if a == inp then return nil end end + return inp + end + }, } local function process_selector(task, sel)