aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-02 12:37:48 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-02 12:37:48 +0100
commit4a538dc83bd4f7f2677760ea7db8ac989fadad85 (patch)
treebb944278ef8fdea67793e14e7844ed12e2b347b0
parentc913b0a1d1f581a40d3302326e2a6bfdb4d66eea (diff)
parentf786fc3053c2a3bc65a8ffe9bb4859f5c904be87 (diff)
downloadrspamd-4a538dc83bd4f7f2677760ea7db8ac989fadad85.tar.gz
rspamd-4a538dc83bd4f7f2677760ea7db8ac989fadad85.zip
Merge pull request #248 from fatalbanana/master
Allow getting message queue ID from Lua
-rw-r--r--src/lua/lua_task.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 96292bee8..c4e595c8b 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -246,6 +246,11 @@ LUA_FUNCTION_DEF (task, get_raw_headers);
*/
LUA_FUNCTION_DEF (task, get_received_headers);
/***
+ * @method task:get_queue_id()
+ * Returns queue ID of the message being processed.
+ */
+LUA_FUNCTION_DEF (task, get_queue_id);
+/***
* @method task:get_resolver()
* Returns ready to use rspamd_resolver object suitable for making asynchronous DNS requests.
* @return {rspamd_resolver} resolver object associated with the task's session
@@ -464,6 +469,7 @@ static const struct luaL_reg tasklib_m[] = {
LUA_INTERFACE_DEF (task, get_header_full),
LUA_INTERFACE_DEF (task, get_raw_headers),
LUA_INTERFACE_DEF (task, get_received_headers),
+ LUA_INTERFACE_DEF (task, get_queue_id),
LUA_INTERFACE_DEF (task, get_resolver),
LUA_INTERFACE_DEF (task, inc_dns_req),
LUA_INTERFACE_DEF (task, get_recipients),
@@ -1237,6 +1243,20 @@ lua_task_get_received_headers (lua_State * L)
}
static gint
+lua_task_get_queue_id (lua_State *L)
+{
+ struct rspamd_task *task = lua_check_task (L, 1);
+
+ if (task && task->queue_id != NULL && task->queue_id != "undef") {
+ lua_pushstring (L, task->queue_id);
+ return 1;
+ }
+
+ lua_pushnil (L);
+ return 1;
+}
+
+static gint
lua_task_get_resolver (lua_State *L)
{
struct rspamd_task *task = lua_check_task (L, 1);