]> source.dussan.org Git - rspamd.git/commitdiff
[Rework] Continue aliases changes
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 2 Apr 2019 18:38:32 +0000 (19:38 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 2 Apr 2019 18:38:32 +0000 (19:38 +0100)
src/libserver/task.c
src/plugins/lua/clickhouse.lua

index dcad1a1aba8480e6ed76df485a0129f32573aeeb..d0ef40621178dbfb1c9004732ab48f312c519f5a 100644 (file)
@@ -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;
                }
index 924b629c894dd40625672a2f0af6def8fc077ea9..8e07362f85bac2f712cee0d0162a7424000ba9c0 100644 (file)
@@ -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']