diff --git a/data/conf/rspamd/local.d/multimap.conf b/data/conf/rspamd/local.d/multimap.conf index 50bced3e1..6237f0078 100644 --- a/data/conf/rspamd/local.d/multimap.conf +++ b/data/conf/rspamd/local.d/multimap.conf @@ -6,10 +6,16 @@ RCPT_MAILCOW_DOMAIN { RCPT_WANTS_SUBJECT_TAG { type = "rcpt"; - filter = "email:addr" + filter = "email:addr"; map = "redis://RCPT_WANTS_SUBJECT_TAG"; } +RCPT_WANTS_SUBFOLDER_TAG { + type = "rcpt"; + filter = "email:addr"; + map = "redis://RCPT_WANTS_SUBFOLDER_TAG"; +} + WHITELISTED_FWD_HOST { type = "ip"; map = "redis://WHITELISTED_FWD_HOST"; diff --git a/data/conf/rspamd/lua/rspamd.local.lua b/data/conf/rspamd/lua/rspamd.local.lua index 75dbe8514..11617853b 100644 --- a/data/conf/rspamd/lua/rspamd.local.lua +++ b/data/conf/rspamd/lua/rspamd.local.lua @@ -30,8 +30,9 @@ rspamd_config:register_symbol({ end local wants_subject_tag = task:get_symbol("RCPT_WANTS_SUBJECT_TAG") + local wants_subfolder_tag = task:get_symbol("RCPT_WANTS_SUBFOLDER_TAG") - if wants_subject_tag == 1 then + if wants_subject_tag then rspamd_logger.infox("user wants subject modified for tagged mail") local sbj = task:get_header('Subject') new_sbj = '=?UTF-8?B?' .. tostring(util.encode_base64('[' .. tag .. '] ' .. sbj)) .. '?=' @@ -39,7 +40,7 @@ rspamd_config:register_symbol({ remove_headers = {['Subject'] = 1}, add_headers = {['Subject'] = new_sbj} }) - elseif wants_subject_tag == 2 then + elseif wants_subfolder_tag then rspamd_logger.infox("Add X-Moo-Tag header") task:set_milter_reply({ add_headers = {['X-Moo-Tag'] = 'YES'} diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php index 5c462928f..cb804e69a 100644 --- a/data/web/inc/functions.mailbox.inc.php +++ b/data/web/inc/functions.mailbox.inc.php @@ -1298,6 +1298,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) { if (isset($_data['tagged_mail_handler']) && $_data['tagged_mail_handler'] == "subject") { try { $redis->hSet('RCPT_WANTS_SUBJECT_TAG', $username, 1); + $redis->hDel('RCPT_WANTS_SUBFOLDER_TAG', $username); } catch (RedisException $e) { $_SESSION['return'] = array( @@ -1309,7 +1310,8 @@ function mailbox($_action, $_type, $_data = null, $attr = null) { } else if (isset($_data['tagged_mail_handler']) && $_data['tagged_mail_handler'] == "subfolder") { try { - $redis->hSet('RCPT_WANTS_SUBJECT_TAG', $username, 2); + $redis->hSet('RCPT_WANTS_SUBFOLDER_TAG', $username, 1); + $redis->hDel('RCPT_WANTS_SUBJECT_TAG', $username); } catch (RedisException $e) { $_SESSION['return'] = array( @@ -1322,6 +1324,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) { else { try { $redis->hDel('RCPT_WANTS_SUBJECT_TAG', $username); + $redis->hDel('RCPT_WANTS_SUBFOLDER_TAG', $username); } catch (RedisException $e) { $_SESSION['return'] = array( @@ -2631,11 +2634,10 @@ function mailbox($_action, $_type, $_data = null, $attr = null) { $_data = $_SESSION['mailcow_cc_username']; } try { - $wants_subject_tag = $redis->hGet('RCPT_WANTS_SUBJECT_TAG', $_data); - if ($wants_subject_tag == 1) { + if ($redis->hGet('RCPT_WANTS_SUBJECT_TAG', $_data)) { return "subject"; } - elseif ($wants_subject_tag == 2) { + elseif ($redis->hGet('RCPT_WANTS_SUBFOLDER_TAG', $_data)) { return "subfolder"; } else {