diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-11 14:12:35 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-11 14:12:35 +0000 |
commit | 8cdf6a7b1640ca4c850ea51fa6a48e1f9ae40a71 (patch) | |
tree | 2556a87f3a6afa9605817bfe8e457ad16edabad9 /src/libstat/backends | |
parent | 70d0787fcb1d2fd1db2b64bfa948e91d3dd54fb9 (diff) | |
download | rspamd-8cdf6a7b1640ca4c850ea51fa6a48e1f9ae40a71.tar.gz rspamd-8cdf6a7b1640ca4c850ea51fa6a48e1f9ae40a71.zip |
Add generic routine to get task's recipient
Diffstat (limited to 'src/libstat/backends')
-rw-r--r-- | src/libstat/backends/redis_backend.c | 29 | ||||
-rw-r--r-- | src/libstat/backends/sqlite3_backend.c | 23 |
2 files changed, 7 insertions, 45 deletions
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c index f1857871e..9de80cedb 100644 --- a/src/libstat/backends/redis_backend.c +++ b/src/libstat/backends/redis_backend.c @@ -108,9 +108,6 @@ rspamd_redis_expand_object (const gchar *pattern, { gsize tlen = 0; const gchar *p = pattern, *elt; - InternetAddressList *ia; - InternetAddress *iaelt; - InternetAddressMailbox *imb; gchar *d, *end; enum { just_char, @@ -153,17 +150,10 @@ rspamd_redis_expand_object (const gchar *pattern, } break; case 'r': - ia = GET_TASK_ELT (task, rcpt_envelope); - if (ia != NULL) { - iaelt = internet_address_list_get_address (ia, 0); - imb = INTERNET_ADDRESS_IS_MAILBOX (iaelt) ? - INTERNET_ADDRESS_MAILBOX (iaelt) : NULL; + elt = rspamd_task_get_principal_recipient (task); - elt = (imb ? internet_address_mailbox_get_addr (imb) : NULL); - - if (elt) { - tlen += strlen (elt); - } + if (elt) { + tlen += strlen (elt); } break; case 'l': @@ -246,17 +236,10 @@ rspamd_redis_expand_object (const gchar *pattern, } break; case 'r': - ia = GET_TASK_ELT (task, rcpt_envelope); - if (ia != NULL) { - iaelt = internet_address_list_get_address (ia, 0); - imb = INTERNET_ADDRESS_IS_MAILBOX (iaelt) ? - INTERNET_ADDRESS_MAILBOX (iaelt) : NULL; + elt = rspamd_task_get_principal_recipient (task); - elt = (imb ? internet_address_mailbox_get_addr (imb) : NULL); - - if (elt) { - d += rspamd_strlcpy (d, elt, end - d); - } + if (elt) { + d += rspamd_strlcpy (d, elt, end - d); } break; case 'l': diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c index 3e05bee80..ab1d24a71 100644 --- a/src/libstat/backends/sqlite3_backend.c +++ b/src/libstat/backends/sqlite3_backend.c @@ -303,33 +303,12 @@ rspamd_sqlite3_get_user (struct rspamd_stat_sqlite3_db *db, gint64 id = 0; /* Default user is 0 */ gint rc, err_idx; const gchar *user = NULL; - const InternetAddress *ia; struct rspamd_task **ptask; lua_State *L = db->L; GString *tb; if (db->cbref_user == -1) { - if (task->deliver_to != NULL) { - /* Use deliver-to value if presented */ - user = task->deliver_to; - } - if (task->user != NULL) { - /* Use user value if presented */ - user = task->user; - } - else if (task->rcpt_envelope != NULL) { - /* Check envelope recipients */ - if (internet_address_list_length (task->rcpt_envelope) == 1) { - /* XXX: we support now merely single recipient statistics */ - ia = internet_address_list_get_address (task->rcpt_envelope, 0); - - if (ia != NULL) { - user = internet_address_mailbox_get_addr ( - INTERNET_ADDRESS_MAILBOX (ia)); - } - } - } - /* XXX: We ignore now mime recipients as they could be easily forged */ + user = rspamd_task_get_principal_recipient (task); } else { /* Execute lua function to get userdata */ |