summaryrefslogtreecommitdiffstats
path: root/lualib/lua_maps.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-11-05 13:31:57 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-11-19 12:44:13 +0000
commit78a67ee1754f245995887f5c1909b5e3caa4a313 (patch)
tree008b3d0f0ff97c1919f5a5b27943550fe2e3206a /lualib/lua_maps.lua
parentba3fd03e8cac2e269a2d36f32fb8acbf6d2f2604 (diff)
downloadrspamd-78a67ee1754f245995887f5c1909b5e3caa4a313.tar.gz
rspamd-78a67ee1754f245995887f5c1909b5e3caa4a313.zip
[Minor] Also allow to pass callback in the `get_key` method
Diffstat (limited to 'lualib/lua_maps.lua')
-rw-r--r--lualib/lua_maps.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua
index 9ebdbbbe6..95828fe13 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