From: Andrew Lewis Date: Wed, 15 Feb 2017 14:19:51 +0000 (+0200) Subject: [Feature] Support setting subject in force actions module X-Git-Tag: 1.5.0~100^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=125b8dfd0cc0257e66401b4ec66d29404012e10f;p=rspamd.git [Feature] Support setting subject in force actions module --- diff --git a/src/plugins/lua/force_actions.lua b/src/plugins/lua/force_actions.lua index caee6f264..6c01afc2b 100644 --- a/src/plugins/lua/force_actions.lua +++ b/src/plugins/lua/force_actions.lua @@ -25,7 +25,7 @@ local rspamd_cryptobox_hash = require "rspamd_cryptobox_hash" local rspamd_expression = require "rspamd_expression" local rspamd_logger = require "rspamd_logger" -local function gen_cb(expr, act, pool, message) +local function gen_cb(expr, act, pool, message, subject) local function parse_atom(str) local atom = table.concat(fun.totable(fun.take_while(function(c) @@ -54,6 +54,9 @@ local function gen_cb(expr, act, pool, message) return function(task) if e:process(task) == 1 then + if subject then + task:set_metric_subject(subject) + end if message then task:set_pre_result(act, message) else @@ -77,15 +80,16 @@ local function configure_module() for action, expressions in pairs(opts.actions) do if type(expressions) == 'table' then for _, expr in ipairs(expressions) do - local message + local message, subject if type(expr) == 'table' then + subject = expr[3] message = expr[2] expr = expr[1] else message = (opts.messages or E)[expr] end if type(expr) == 'string' then - local cb, atoms = gen_cb(expr, action, rspamd_config:get_mempool(), message) + local cb, atoms = gen_cb(expr, action, rspamd_config:get_mempool(), message, subject) if cb and atoms then local h = rspamd_cryptobox_hash.create() h:update(expr)