aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/protocol.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-05 11:17:44 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-05 11:18:56 +0000
commit8fb2e907d41b71464a147e5e962f0f39d6a24b24 (patch)
tree3a2496e2124cbcf0451382123b56191e43abad1f /src/libserver/protocol.c
parent0fd7052b5e5bd03c874b063d2958035a0b4082d6 (diff)
downloadrspamd-8fb2e907d41b71464a147e5e962f0f39d6a24b24.tar.gz
rspamd-8fb2e907d41b71464a147e5e962f0f39d6a24b24.zip
[Minor] Add `compat_messages` for compatibility with legacy protocol
MFH: true
Diffstat (limited to 'src/libserver/protocol.c')
-rw-r--r--src/libserver/protocol.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 566f7bc4b..668c21ee2 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -1044,8 +1044,25 @@ rspamd_protocol_write_ucl (struct rspamd_task *task)
ucl_object_insert_key (top, obj, h, 0, false);
}
- ucl_object_insert_key (top, ucl_object_ref (task->messages),
+ if (G_UNLIKELY (task->cfg->compat_messages)) {
+ const ucl_object_t *cur;
+ ucl_object_t *msg_object;
+ ucl_object_iter_t iter = NULL;
+
+ msg_object = ucl_object_typed_new (UCL_ARRAY);
+
+ while ((cur = ucl_object_iterate (task->messages, &iter, true)) != NULL) {
+ if (cur->type == UCL_STRING) {
+ ucl_array_append (msg_object, ucl_object_ref (cur));
+ }
+ }
+
+ ucl_object_insert_key (top, msg_object, "messages", 0, false);
+ }
+ else {
+ 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) {