From 125b8dfd0cc0257e66401b4ec66d29404012e10f Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Wed, 15 Feb 2017 16:19:51 +0200 Subject: [PATCH] [Feature] Support setting subject in force actions module --- src/plugins/lua/force_actions.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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) -- 2.39.5