From ab4ec231e0a0bfbc9bd993be30b7c4ca220fcc2c Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 27 Nov 2022 21:54:17 +0000 Subject: [PATCH] [Minor] Allow to register symbols from settings explicitly --- src/plugins/lua/settings.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua index 4eb9ac869..e86b7f6b2 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 -- 2.39.5