Skip to content

Commit

Permalink
[Minor] Allow to use external map in explicitly set settings
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Nov 27, 2022
1 parent ab4ec23 commit bcb71e6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/plugins/lua/settings.lua
Expand Up @@ -169,6 +169,7 @@ local function check_query_settings(task)

if settings_id and settings_initialized then
local cached = lua_settings.settings_by_id(settings_id)
lua_util.debugm(N, task, "check settings id for %s", settings_id)

if cached then
local elt = cached.settings
Expand All @@ -180,8 +181,8 @@ local function check_query_settings(task)
if nset then
elt.apply = lua_util.override_defaults(nset, elt.apply)
end
return elt.apply, cached, cached.priority or 1
end
return elt.apply, cached, cached.priority or 1
else
rspamd_logger.warnx(task, 'no settings id "%s" has been found', settings_id)
if nset then
Expand Down Expand Up @@ -333,6 +334,7 @@ local function check_settings(task)
end

local min_pri = 1
lua_util.debugm(N, task, "hui: %s", id_elt)
if query_apply then
if priority >= min_pri then
-- Do not check lower or equal priorities
Expand All @@ -345,6 +347,17 @@ local function check_settings(task)

return
end
elseif id_elt and type(id_elt.settings) == 'table' and id_elt.settings.external_map then
local external_map = id_elt.settings.external_map
local selector_result = external_map.selector(task)

if selector_result then
external_map.map:get_key(selector_result, nil, task)
-- No more selection logic
return
else
rspamd_logger.infox("cannot query selector to make external map request")
end
end

-- Do not waste resources
Expand Down

0 comments on commit bcb71e6

Please sign in to comment.