From 44e17e1bbd9cee25c019f47511b13edf2c770df4 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 13 Feb 2015 12:58:45 +0000 Subject: [PATCH] Add task:get_content() method. --- src/lua/lua_task.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index b07b6e93c..3e09934c7 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -162,6 +162,12 @@ local function phishing_cb(task) end */ LUA_FUNCTION_DEF (task, get_urls); +/*** + * @method task:get_content() + * Get raw content for the specified task + * @return {string} the data contained in the task + */ +LUA_FUNCTION_DEF (task, get_content); /*** * @method task:get_urls() * Get all email addresses found in a message. @@ -439,6 +445,7 @@ static const struct luaL_reg tasklib_m[] = { LUA_INTERFACE_DEF (task, insert_result), LUA_INTERFACE_DEF (task, set_pre_result), LUA_INTERFACE_DEF (task, get_urls), + LUA_INTERFACE_DEF (task, get_content), LUA_INTERFACE_DEF (task, get_emails), LUA_INTERFACE_DEF (task, get_text_parts), LUA_INTERFACE_DEF (task, get_parts), @@ -956,6 +963,20 @@ lua_task_get_urls (lua_State * L) return 1; } +static gint +lua_task_get_content (lua_State * L) +{ + struct rspamd_task *task = lua_check_task (L); + + if (task) { + lua_pushlstring (L, task->msg.start, task->msg.len); + return 1; + } + + lua_pushnil (L); + return 1; +} + static gint lua_task_get_emails (lua_State * L) { -- 2.39.5