commit 78a67ee: [Minor] Also allow to pass callback in the `get_key` method

Vsevolod Stakhov vsevolod at rspamd.com
Sat Nov 19 20:28:05 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-11-05 13:31:57 +0000
URL: https://github.com/rspamd/rspamd/commit/78a67ee1754f245995887f5c1909b5e3caa4a313

[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


More information about the Commits mailing list