diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-05-27 15:36:19 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-05-29 19:55:39 +0100 |
commit | a3745962855863cb180d7a5b6cf86ad46a7570b8 (patch) | |
tree | ad527a1c4905ab88dbc8597a004a16687df500f0 /lualib | |
parent | 770e290862b105ed5700a1c769452adc39bb77b9 (diff) | |
download | rspamd-a3745962855863cb180d7a5b6cf86ad46a7570b8.tar.gz rspamd-a3745962855863cb180d7a5b6cf86ad46a7570b8.zip |
[Minor] Propagate on_load via Lua wrapper
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_maps.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua index e3ce2af20..d65481177 100644 --- a/lualib/lua_maps.lua +++ b/lualib/lua_maps.lua @@ -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() |