From: Vsevolod Stakhov Date: Fri, 13 Feb 2015 12:58:45 +0000 (+0000) Subject: Add task:get_content() method. X-Git-Tag: 0.8.2~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44e17e1bbd9cee25c019f47511b13edf2c770df4;p=thirdparty%2Frspamd.git Add task:get_content() method. --- diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index b07b6e93c5..3e09934c74 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) {