From 7dc4e31c777d83ae2de2fdceaaaa2088ec675a23 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 29 Jul 2016 12:29:37 +0100 Subject: [PATCH] [Feature] Allow to register metric symbols from multimap --- src/plugins/lua/multimap.lua | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index b19740231..e68402572 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -586,11 +586,40 @@ if opts and type(opts) == 'table' then -- add fake symbol to check all maps inside a single callback if any(function(r) return not r['prefilter'] end, rules) then for i,rule in ipairs(rules) do - rspamd_config:register_symbol({ + local id = rspamd_config:register_symbol({ type = 'normal', name = rule['symbol'], callback = gen_multimap_callback(rule), }) + if rule['symbols'] then + -- Find allowed symbols by this map + rule['symbols_set'] = {} + each(function(s) + rspamd_config:register_symbol({ + type = 'virtual', + name = s, + parent = id + }) + rule['symbols_set'][s] = 1 + end, rule['symbols']) + end + if rule['score'] then + -- Register metric symbol + local description = 'multimap symbol' + local group = 'multimap' + if rule['description'] then + description = rule['description'] + end + if rule['group'] then + group = rule['group'] + end + rspamd_config:set_metric_symbol({ + name = rule['symbol'], + score = rule['score'], + description = description, + group = group + }) + end end end -- 2.39.5