From 1e9de7b24eb911e318a72b66e27b8f4922d0e2f0 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 6fee606c4..c830a48ef 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -157,6 +157,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. @@ -434,6 +440,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), @@ -953,6 +960,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