]> source.dussan.org Git - rspamd.git/commitdiff
Use messages for pre-results.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 23 Sep 2014 15:57:38 +0000 (16:57 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 23 Sep 2014 15:57:38 +0000 (16:57 +0100)
src/libserver/protocol.c
src/lua/lua_task.c

index 7dadc65ec5b0af331fd68527dcf0004c623f564d..726da91181a7c64b9fcbbe320419f787796f7daa 100644 (file)
@@ -725,7 +725,7 @@ rspamd_ucl_tolegacy_output (struct rspamd_task *task,
        GString *out)
 {
        const ucl_object_t *metric, *score,
-       *required_score, *is_spam, *elt;
+       *required_score, *is_spam, *elt, *cur;
        ucl_object_iter_t iter = NULL;
 
        metric = ucl_object_find_key (top, DEFAULT_METRIC);
@@ -761,6 +761,18 @@ rspamd_ucl_tolegacy_output (struct rspamd_task *task,
                                ucl_object_tostring (elt));
                }
        }
+
+       elt = ucl_object_find_key (top, "messages");
+       if (elt != NULL) {
+               iter = NULL;
+               while ((cur = ucl_iterate_object (elt, &iter, true)) != NULL) {
+                       if (cur->type == UCL_STRING) {
+                               g_string_append_printf (out, "Message: %s\r\n",
+                                               ucl_object_tostring (cur));
+                       }
+               }
+       }
+
        g_string_append_printf (out, "Message-ID: %s\r\n", task->message_id);
 }
 
@@ -809,11 +821,6 @@ rspamd_protocol_http_reply (struct rspamd_http_message *msg,
                ucl_object_insert_key (top, obj, h, 0, false);
        }
 
-       if (task->pre_result.str != NULL) {
-               ucl_object_insert_key (top, ucl_object_fromstring (task->pre_result.str),
-                               "reason", 0, false);
-       }
-
        if (task->messages != NULL) {
                ucl_object_insert_key (top, rspamd_str_list_ucl (
                                task->messages), "messages", 0, false);
index cb0d7325bc10dd67b8a6ff5cc8d92825416a8f1b..d190373dd1376c641535dc67de5f51c2d154ca75 100644 (file)
@@ -800,6 +800,7 @@ 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);
                        }
                        else {
                                task->pre_result.str = "unknown";