]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Also allow to pass callback in the `get_key` method
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 5 Nov 2022 13:31:57 +0000 (13:31 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 19 Nov 2022 12:44:13 +0000 (12:44 +0000)
lualib/lua_maps.lua

index 9ebdbbbe64692fce8bc7aa66835263095b10b2a5..95828fe1310dc96f796924bd1ececaf3f3d6b277 100644 (file)
@@ -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