From: Vsevolod Stakhov Date: Tue, 2 Apr 2019 18:38:32 +0000 (+0100) Subject: [Rework] Continue aliases changes X-Git-Tag: 1.9.1~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=038039fc3599792d01863eae66d6ebc7f12cc7dc;p=rspamd.git [Rework] Continue aliases changes --- diff --git a/src/libserver/task.c b/src/libserver/task.c index dcad1a1ab..d0ef40621 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -1231,22 +1231,39 @@ rspamd_task_write_ialist (struct rspamd_task *task, rspamd_fstring_t *res = logbuf, *varbuf; rspamd_ftok_t var = {.begin = NULL, .len = 0}; struct rspamd_email_address *addr; - gint i, nchars = 0, cur_chars; + gint i, nchars = 0, wr = 0, cur_chars; + gboolean has_orig = FALSE; if (addrs && lim <= 0) { lim = addrs->len; } + PTR_ARRAY_FOREACH (addrs, i, addr) { + if (addr->flags & RSPAMD_EMAIL_ADDR_ORIGINAL) { + has_orig = TRUE; + break; + } + } + varbuf = rspamd_fstring_new (); PTR_ARRAY_FOREACH (addrs, i, addr) { - if (i >= lim) { + if (wr >= lim) { break; } + + if (has_orig) { + /* Report merely original addresses */ + if (!(addr->flags & RSPAMD_EMAIL_ADDR_ORIGINAL)) { + continue; + } + } + cur_chars = addr->addr_len; varbuf = rspamd_fstring_append (varbuf, addr->addr, cur_chars); nchars += cur_chars; + wr ++; if (varbuf->len > 0) { if (i != lim - 1) { @@ -1254,7 +1271,7 @@ rspamd_task_write_ialist (struct rspamd_task *task, } } - if (i >= max_log_elts || nchars >= max_log_elts * 10) { + if (wr >= max_log_elts || nchars >= max_log_elts * 10) { varbuf = rspamd_fstring_append (varbuf, "...", 3); break; } diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index 924b629c8..8e07362f8 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -340,7 +340,7 @@ local function clickhouse_collect(task) local mime_domain = '' local mime_user = '' if task:has_from('mime') then - local from = task:get_from('mime')[1] + local from = task:get_from({'mime','orig'})[1] if from then mime_domain = from['domain'] mime_user = from['user']