summaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-11-02 13:38:57 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-11-02 13:38:57 +0000
commita1bdb1f4f56ea6b3877e9c9d030d085728f0d566 (patch)
tree58ad60e9c78d8dfbcd06f5d314a5c21465f8f1e2 /src/libserver
parent99488d5a2a601f4a4ae30036b07189ff9c17ed3c (diff)
downloadrspamd-a1bdb1f4f56ea6b3877e9c9d030d085728f0d566.tar.gz
rspamd-a1bdb1f4f56ea6b3877e9c9d030d085728f0d566.zip
[Rework] Make rspamd protocol messages useful
Each message is now represented by a string and category, so messages in metric is an UCL object of the following format: { "category": "string" } The significant category is `smtp_message` which should be used by rmilter to send a custom SMTP reply to a client.
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/protocol.c6
-rw-r--r--src/libserver/task.c5
-rw-r--r--src/libserver/task.h2
3 files changed, 5 insertions, 8 deletions
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 */