From: Vsevolod Stakhov Date: Sun, 27 Nov 2022 21:54:17 +0000 (+0000) Subject: [Minor] Allow to register symbols from settings explicitly X-Git-Tag: 3.5~183 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ab4ec231e0a0bfbc9bd993be30b7c4ca220fcc2c;p=thirdparty%2Frspamd.git [Minor] Allow to register symbols from settings explicitly --- diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua index 4eb9ac8694..e86b7f6b25 100644 --- a/src/plugins/lua/settings.lua +++ b/src/plugins/lua/settings.lua @@ -1323,6 +1323,26 @@ elseif set_section and type(set_section) == "table" then -- Postponed settings init is needed to ensure that all symbols have been -- registered BEFORE settings plugin. Otherwise, we can have inconsistent settings expressions fun.each(function(_, elt) + if elt.register_symbols then + for k,v in pairs(elt.register_symbols) do + local rtb = { + type = 'virtual', + parent = module_sym_id, + } + if type(k) == 'number' and type(v) == 'string' then + rtb.name = v + elseif type(k) == 'string' then + rtb.name = k + if type(v) == 'table' then + for kk,vv in pairs(v) do + -- Enrich table wih extra values + rtb[kk] = vv + end + end + end + rspamd_config:register_symbol(rtb) + end + end if elt.apply and elt.apply.symbols then -- Register virtual symbols for k,v in pairs(elt.apply.symbols) do