if not senabled[1] then
-- Transform map to a list
local nlist = {}
- if not settings.symbols then
- settings.symbols = {}
+ if not apply.scores then
+ apply.scores = {}
end
for k,v in pairs(senabled) do
if tonumber(v) then
-- Move to symbols as well
- settings.symbols[k] = tonumber(v)
+ apply.scores[k] = tonumber(v)
lua_util.debugm('settings', rspamd_config,
'set symbol %s -> %s for settings %s', k, v, name)
end
if apply.symbols then
-- Check if added symbols are enabled
- for _,s in ipairs(apply.symbols) do
+ for _,s in pairs(apply.symbols) do
if not symhash[s] then
lua_util.debugm('settings', rspamd_config,
'added symbol %s to symbols_enabled for %s', s, name)
if to_apply.symbols then
-- Add symbols, specified in the settings
if #to_apply.symbols > 0 then
- fun.each(function(val)
+ -- Array like symbols
+ for _,val in ipairs(to_apply.symbols) do
task:insert_result(val, 1.0)
- end,
- fun.filter(function(elt) return type(elt) == 'string' end,
- to_apply.symbols))
+ end
else
-- Object like symbols
- fun.each(function(k, val)
- task:insert_result(k, val.score or 1.0, val.options or {})
- end,
- fun.filter(function(_, elt) return type(elt) == 'table' end,
- to_apply.symbols))
+ for k,v in pairs(to_apply.symbols) do
+ if type(v) == 'table' then
+ task:insert_result(k, v.score or 1.0, v.options or {})
+ elseif tonumber(v) then
+ task:insert_result(k, tonumber(v))
+ end
+ end
end
end
if elt.apply.symbols then
-- Register virtual symbols
- for _,sym in ipairs(elt.apply.symbols) do
- rspamd_config:register_symbol{
- name = sym,
- type = 'virtual,ghost',
- }
+ for k,v in pairs(elt.apply.symbols) do
+ if type(k) == 'number' and type(v) == 'string' then
+ rspamd_config:register_symbol{
+ name = v,
+ type = 'virtual,ghost',
+ }
+ elseif type(k) == 'string' then
+ rspamd_config:register_symbol{
+ name = k,
+ type = 'virtual,ghost',
+ }
+ end
end
end
else