From 78a67ee1754f245995887f5c1909b5e3caa4a313 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 5 Nov 2022 13:31:57 +0000 Subject: [PATCH] [Minor] Also allow to pass callback in the `get_key` method --- lualib/lua_maps.lua | 8 +++++--- 1 file 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 -- 2.39.5