summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libmime/message.c3
-rw-r--r--src/libserver/protocol.c6
-rw-r--r--src/libserver/task.c5
-rw-r--r--src/libserver/task.h2
-rw-r--r--src/lua/lua_task.c19
-rw-r--r--src/plugins/spf.c5
6 files changed, 26 insertions, 14 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index 7fc22d1ef..d9296964b 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -1052,6 +1052,9 @@ process_text_part (struct rspamd_task *task,
task->pre_result.action = METRIC_ACTION_REJECT;
task->pre_result.str = "Gtube pattern";
+ ucl_object_insert_key (task->messages,
+ ucl_object_fromstring ("Gtube pattern"), "smtp_message", 0,
+ false);
rspamd_task_insert_result (task, GTUBE_SYMBOL, 0, NULL);
return;
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 95490ea4c..e4a042610 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -1014,10 +1014,8 @@ rspamd_protocol_write_ucl (struct rspamd_task *task)
ucl_object_insert_key (top, obj, h, 0, false);
}
- if (task->messages != NULL) {
- ucl_object_insert_key (top, rspamd_str_list_ucl (
- task->messages), "messages", 0, false);
- }
+ ucl_object_insert_key (top, ucl_object_ref (task->messages),
+ "messages", 0, false);
if (task->cfg->log_urls || (task->flags & RSPAMD_TASK_FLAG_EXT_URLS)) {
if (g_hash_table_size (task->urls) > 0) {
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 6b92593de..b9fca4d4a 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -128,6 +128,7 @@ rspamd_task_new (struct rspamd_worker *worker, struct rspamd_config *cfg)
new_task->pre_result.action = METRIC_ACTION_MAX;
new_task->message_id = new_task->queue_id = "undef";
+ new_task->messages = ucl_object_typed_new (UCL_OBJECT);
return new_task;
}
@@ -233,9 +234,7 @@ rspamd_task_free (struct rspamd_task *task)
rspamd_email_address_unref (task->from_envelope);
}
- if (task->messages) {
- g_list_free (task->messages);
- }
+ ucl_object_unref (task->messages);
if (task->http_conn != NULL) {
rspamd_http_connection_reset (task->http_conn);
diff --git a/src/libserver/task.h b/src/libserver/task.h
index 915d58aa3..f46e09379 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -163,7 +163,7 @@ struct rspamd_task {
struct rspamd_email_address *from_envelope;
enum rspamd_newlines_type nlines_type; /**< type of newlines (detected on most of headers */
- GList *messages; /**< list of messages that would be reported */
+ ucl_object_t *messages; /**< list of messages that would be reported */
struct rspamd_re_runtime *re_rt; /**< regexp runtime */
GPtrArray *stat_runtimes; /**< backend runtime */
struct rspamd_config *cfg; /**< pointer to config object */
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index e686876f7..dcbdfc9e1 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -1093,7 +1093,9 @@ lua_task_set_pre_result (lua_State * L)
action_str = rspamd_mempool_strdup (task->task_pool,
luaL_checkstring (L, 3));
task->pre_result.str = action_str;
- task->messages = g_list_prepend (task->messages, action_str);
+ ucl_object_insert_key (task->messages,
+ ucl_object_fromstring (action_str), "smtp_message", 0,
+ false);
}
else {
task->pre_result.str = "unknown";
@@ -1123,12 +1125,19 @@ static gint
lua_task_append_message (lua_State * L)
{
struct rspamd_task *task = lua_check_task (L, 1);
- gchar *message;
+ const gchar *message = luaL_checkstring (L, 2), *category;
if (task != NULL) {
- message= rspamd_mempool_strdup (task->task_pool,
- luaL_checkstring (L, 2));
- task->messages = g_list_prepend (task->messages, message);
+ if (lua_type (L, 3) == LUA_TSTRING) {
+ category = luaL_checkstring (L, 3);
+ }
+ else {
+ category = "unknown";
+ }
+
+ ucl_object_insert_key (task->messages,
+ ucl_object_fromstring (message), category, 0,
+ true);
}
else {
return luaL_error (L, "invalid arguments");
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index 613c7a189..98ca09c37 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -465,7 +465,10 @@ spf_check_element (struct spf_resolved *rec, struct spf_addr *addr,
spf_symbol,
1,
opts);
- task->messages = g_list_prepend (task->messages, (gpointer)spf_message);
+ ucl_object_insert_key (task->messages,
+ ucl_object_fromstring (spf_message), "spf", 0,
+ false);
+
return TRUE;
}