]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Propagate on_load via Lua wrapper
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 27 May 2023 14:36:19 +0000 (15:36 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 29 May 2023 18:55:39 +0000 (19:55 +0100)
lualib/lua_maps.lua

index e3ce2af20e13b04f2064656fbf6db3920801b26c..d65481177fdfd8cecb28835d62fb87aa3e16fd0e 100644 (file)
@@ -231,6 +231,12 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback)
       end
 
       return nil
+    end,
+    foreach = function(t, cb)
+      return t.__data:foreach(cb)
+    end,
+    on_load = function(t, cb)
+      t.__data:on_load(cb)
     end
   }
   local ret_mt = {
@@ -414,6 +420,20 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback)
 
               return nil
             end
+            ret.foreach = function(_, func)
+              for k,v in pairs(ret.__data) do
+                if not func(k, v) then
+                  return false
+                end
+              end
+
+              return true
+            end
+            ret.on_load = function(_, cb)
+              rspamd_config:add_on_load(function(_, _, _)
+                cb()
+              end)
+            end
 
             maps_cache[cache_key] = ret
             maybe_register_selector()