aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_task.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-13 17:49:35 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-13 17:49:35 +0000
commitbaee02f1f70d1ceedf0bf0c5788c55ea0ddb9561 (patch)
treee0a8b685eb7953606d06bd7b25b78c4bd24534dc /src/lua/lua_task.c
parenteb91f13938c023c1e7cb5db4fae0f5d83ec74e1a (diff)
downloadrspamd-baee02f1f70d1ceedf0bf0c5788c55ea0ddb9561.tar.gz
rspamd-baee02f1f70d1ceedf0bf0c5788c55ea0ddb9561.zip
[Minor] Add Lua API to get filename
Diffstat (limited to 'src/lua/lua_task.c')
-rw-r--r--src/lua/lua_task.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index a98f4d97a..89f35e90d 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -175,6 +175,13 @@ LUA_FUNCTION_DEF (task, has_urls);
LUA_FUNCTION_DEF (task, get_content);
/***
+ * @method task:get_filename()
+ * Returns filename for a specific task
+ * @return {string|nil} filename or nil if unknown
+ */
+LUA_FUNCTION_DEF (task, get_filename);
+
+/***
* @method task:get_rawbody()
* Get raw body for the specified task
* @return {text} the data contained in the task
@@ -855,6 +862,7 @@ static const struct luaL_reg tasklib_m[] = {
LUA_INTERFACE_DEF (task, has_urls),
LUA_INTERFACE_DEF (task, get_urls),
LUA_INTERFACE_DEF (task, get_content),
+ LUA_INTERFACE_DEF (task, get_filename),
LUA_INTERFACE_DEF (task, get_rawbody),
LUA_INTERFACE_DEF (task, get_emails),
LUA_INTERFACE_DEF (task, get_text_parts),
@@ -1535,6 +1543,26 @@ lua_task_get_content (lua_State * L)
}
static gint
+lua_task_get_filename (lua_State * L)
+{
+ struct rspamd_task *task = lua_check_task (L, 1);
+
+ if (task) {
+ if (task->msg.fpath) {
+ lua_pushstring (L, task->msg.fpath);
+ }
+ else {
+ lua_pushnil (L);
+ }
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 1;
+}
+
+static gint
lua_task_get_rawbody (lua_State * L)
{
struct rspamd_task *task = lua_check_task (L, 1);