From: Vsevolod Stakhov Date: Tue, 23 Sep 2014 15:57:38 +0000 (+0100) Subject: Use messages for pre-results. X-Git-Tag: 0.7.1~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c132cd323144a4977d2df16b4d180008663a88cd;p=rspamd.git Use messages for pre-results. --- diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index 7dadc65ec..726da9118 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -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); diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index cb0d7325b..d190373dd 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -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";