aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_task.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-19 13:58:07 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-19 13:58:07 +0100
commit6b909e7ee5b4f843c97df7685a673cead85de10a (patch)
tree51326c1f091c2c920da5d8fe5ae77a9dd6a54613 /src/lua/lua_task.c
parent762fdd196a1e9cc8317a7ae87b11acd7f817871e (diff)
downloadrspamd-6b909e7ee5b4f843c97df7685a673cead85de10a.tar.gz
rspamd-6b909e7ee5b4f843c97df7685a673cead85de10a.zip
Add method to detect the full size of message.
Diffstat (limited to 'src/lua/lua_task.c')
-rw-r--r--src/lua/lua_task.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index aa6197a80..d8f14a243 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -443,6 +443,13 @@ LUA_FUNCTION_DEF (task, cache_get);
*/
LUA_FUNCTION_DEF (task, cache_set);
+/***
+ * @method task:get_size()
+ * Returns size of the task in bytes (that includes headers + parts size)
+ * @return {number} size in bytes
+ */
+LUA_FUNCTION_DEF (task, get_size);
+
static const struct luaL_reg tasklib_f[] = {
LUA_INTERFACE_DEF (task, create_empty),
LUA_INTERFACE_DEF (task, create_from_buffer),
@@ -496,6 +503,7 @@ static const struct luaL_reg tasklib_m[] = {
LUA_INTERFACE_DEF (task, set_settings),
LUA_INTERFACE_DEF (task, cache_get),
LUA_INTERFACE_DEF (task, cache_set),
+ LUA_INTERFACE_DEF (task, get_size),
{"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -1729,6 +1737,21 @@ lua_task_get_timeval (lua_State *L)
return 1;
}
+static gint
+lua_task_get_size (lua_State *L)
+{
+ struct rspamd_task *task = lua_check_task (L, 1);
+
+ if (task != NULL) {
+ lua_pushnumber (L, task->msg.len);
+ }
+ else {
+ lua_pushnil (L);
+ }
+
+ return 1;
+}
+
static gint
lua_task_learn (lua_State *L)