commit 2145e48: [Minor] Pass more information about pre_result in task:has_pre_result()

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Jun 15 16:28:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-06-15 17:22:02 +0100
URL: https://github.com/rspamd/rspamd/commit/2145e489461a226739b786b7c7b2a4d17acd366b

[Minor] Pass more information about pre_result in task:has_pre_result()

---
 src/lua/lua_task.c | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index e44bc81b3..25e08e99a 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -2366,15 +2366,45 @@ lua_task_has_pre_result (lua_State * L)
 {
 	LUA_TRACE_POINT;
 	struct rspamd_task *task = lua_check_task (L, 1);
+	gint nret = 1;
 
 	if (task) {
-		lua_pushboolean (L, task->result->passthrough_result != NULL);
+		if (task->result->passthrough_result) {
+			struct rspamd_passthrough_result *pr = task->result->passthrough_result;
+
+			lua_pushboolean (L, true);
+			nret = 4;
+			/* bool, action, message, module */
+
+			if (pr->action) {
+				lua_pushstring(L, rspamd_action_to_str(pr->action->action_type));
+			}
+			else {
+				lua_pushnil(L);
+			}
+
+			if (pr->message) {
+				lua_pushstring(L, pr->message);
+			}
+			else {
+				lua_pushnil(L);
+			}
+			if (pr->module) {
+				lua_pushstring(L, pr->module);
+			}
+			else {
+				lua_pushnil(L);
+			}
+		}
+		else {
+			lua_pushboolean (L, false);
+		}
 	}
 	else {
 		return luaL_error (L, "invalid arguments");
 	}
 
-	return 1;
+	return nret;
 }
 
 static gint


More information about the Commits mailing list