]> source.dussan.org Git - rspamd.git/commitdiff
Add task:get_content() method.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 13 Feb 2015 12:58:45 +0000 (12:58 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 13 Feb 2015 12:58:45 +0000 (12:58 +0000)
src/lua/lua_task.c

index 6fee606c48986d62a3a2a6a997025db0604e3b78..c830a48ef5d753e15ccd26a3f34e9821f863eb0d 100644 (file)
@@ -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)
 {