diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-28 14:36:07 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-28 14:36:07 +0100 |
commit | 557cad5d0aee29dc8900b4fa6922fcff379244d1 (patch) | |
tree | 06fdc0b8f44c2fdd93e9d9f19551b8687806d70c | |
parent | 4174974c5cf7f1ba10667f858d96f9ba5795db09 (diff) | |
download | rspamd-557cad5d0aee29dc8900b4fa6922fcff379244d1.tar.gz rspamd-557cad5d0aee29dc8900b4fa6922fcff379244d1.zip |
[Feature] Allow to get task's subject
-rw-r--r-- | src/lua/lua_task.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 36272ecfe..46fc5da94 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -196,6 +196,12 @@ LUA_FUNCTION_DEF (task, get_request_header); */ LUA_FUNCTION_DEF (task, set_request_header); /*** + * @method task:get_subject() + * Returns task subject (either from the protocol override or from a header) + * @return {string} value of a subject (decoded) + */ +LUA_FUNCTION_DEF (task, get_subject); +/*** * @method task:get_header(name[, case_sensitive]) * Get decoded value of a header specified with optional case_sensitive flag. * By default headers are searched in caseless matter. @@ -817,6 +823,7 @@ static const struct luaL_reg tasklib_m[] = { LUA_INTERFACE_DEF (task, set_from_ip), LUA_INTERFACE_DEF (task, get_from_ip_num), LUA_INTERFACE_DEF (task, get_client_ip), + LUA_INTERFACE_DEF (task, get_subject), LUA_INTERFACE_DEF (task, get_helo), LUA_INTERFACE_DEF (task, set_helo), LUA_INTERFACE_DEF (task, get_hostname), @@ -2587,6 +2594,27 @@ lua_task_get_helo (lua_State *L) } static gint +lua_task_get_subject (lua_State *L) +{ + struct rspamd_task *task = lua_check_task (L, 1); + + if (task) { + if (task->subject != NULL) { + lua_pushstring (L, task->subject); + return 1; + } + else { + lua_pushnil (L); + } + } + else { + return luaL_error (L, "invalid arguments"); + } + + return 1; +} + +static gint lua_task_set_helo (lua_State *L) { struct rspamd_task *task = lua_check_task (L, 1); |