From: Vsevolod Stakhov Date: Sat, 5 Nov 2022 13:31:57 +0000 (+0000) Subject: [Minor] Also allow to pass callback in the `get_key` method X-Git-Tag: 3.5~204^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78a67ee1754f245995887f5c1909b5e3caa4a313;p=thirdparty%2Frspamd.git [Minor] Also allow to pass callback in the `get_key` method --- diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua index 9ebdbbbe64..95828fe131 100644 --- a/lualib/lua_maps.lua +++ b/lualib/lua_maps.lua @@ -99,12 +99,14 @@ end local function rspamd_map_add_from_ucl(opt, mtype, description, callback) local ret = { - get_key = function(t, k) + get_key = function(t, k, key_callback) if t.__data then local result = t.__data:get_key(k) if callback then callback(result) + elseif key_callback then + key_callback(result) else return result end @@ -114,9 +116,9 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback) end } local ret_mt = { - __index = function(t, k) + __index = function(t, k, key_callback) if t.__data then - return t.get_key(k) + return t.get_key(k, key_callback) end return nil