From: Andrew Lewis Date: Fri, 8 Sep 2017 08:09:26 +0000 (+0200) Subject: [Fix] Rewriting subjects via force actions module X-Git-Tag: 1.6.4~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d8e87156ccfeabe184fb01f016ee6726192ab55d;p=thirdparty%2Frspamd.git [Fix] Rewriting subjects via force actions module --- diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index 6ccb832298..dc96704bd6 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -747,7 +747,11 @@ make_rewritten_subject (struct rspamd_metric *metric, struct rspamd_task *task) const gchar *s, *c, *p; gsize slen = 0; - c = metric->subject; + c = rspamd_mempool_get_variable (task->task_pool, "metric_subject"); + + if (c == NULL) { + c = metric->subject; + } if (c == NULL) { c = SPAM_SUBJECT; diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 4c9c23a752..5e1a6b9dbb 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -3921,6 +3921,26 @@ lua_task_set_metric_action (lua_State *L) return 1; } +static gint +lua_task_set_metric_subject (lua_State *L) +{ + struct rspamd_task *task = lua_check_task (L, 1); + const gchar *subject; + + subject = luaL_checkstring (L, 2); + + if (task && subject) { + rspamd_mempool_set_variable (task->task_pool, "metric_subject", + rspamd_mempool_strdup(task->task_pool, subject), NULL); + lua_pushboolean (L, true); + } + else { + return luaL_error (L, "invalid arguments"); + } + + return 1; +} + static gint lua_task_get_protocol_reply (lua_State *L) {