mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2024-12-12 10:45:14 +02:00
rspamd multimap redis stuff doesn't work as expected...
This commit is contained in:
parent
1faeadb786
commit
d58b89528f
@ -6,10 +6,16 @@ RCPT_MAILCOW_DOMAIN {
|
|||||||
|
|
||||||
RCPT_WANTS_SUBJECT_TAG {
|
RCPT_WANTS_SUBJECT_TAG {
|
||||||
type = "rcpt";
|
type = "rcpt";
|
||||||
filter = "email:addr"
|
filter = "email:addr";
|
||||||
map = "redis://RCPT_WANTS_SUBJECT_TAG";
|
map = "redis://RCPT_WANTS_SUBJECT_TAG";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RCPT_WANTS_SUBFOLDER_TAG {
|
||||||
|
type = "rcpt";
|
||||||
|
filter = "email:addr";
|
||||||
|
map = "redis://RCPT_WANTS_SUBFOLDER_TAG";
|
||||||
|
}
|
||||||
|
|
||||||
WHITELISTED_FWD_HOST {
|
WHITELISTED_FWD_HOST {
|
||||||
type = "ip";
|
type = "ip";
|
||||||
map = "redis://WHITELISTED_FWD_HOST";
|
map = "redis://WHITELISTED_FWD_HOST";
|
||||||
|
@ -30,8 +30,9 @@ rspamd_config:register_symbol({
|
|||||||
end
|
end
|
||||||
|
|
||||||
local wants_subject_tag = task:get_symbol("RCPT_WANTS_SUBJECT_TAG")
|
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")
|
rspamd_logger.infox("user wants subject modified for tagged mail")
|
||||||
local sbj = task:get_header('Subject')
|
local sbj = task:get_header('Subject')
|
||||||
new_sbj = '=?UTF-8?B?' .. tostring(util.encode_base64('[' .. tag .. '] ' .. sbj)) .. '?='
|
new_sbj = '=?UTF-8?B?' .. tostring(util.encode_base64('[' .. tag .. '] ' .. sbj)) .. '?='
|
||||||
@ -39,7 +40,7 @@ rspamd_config:register_symbol({
|
|||||||
remove_headers = {['Subject'] = 1},
|
remove_headers = {['Subject'] = 1},
|
||||||
add_headers = {['Subject'] = new_sbj}
|
add_headers = {['Subject'] = new_sbj}
|
||||||
})
|
})
|
||||||
elseif wants_subject_tag == 2 then
|
elseif wants_subfolder_tag then
|
||||||
rspamd_logger.infox("Add X-Moo-Tag header")
|
rspamd_logger.infox("Add X-Moo-Tag header")
|
||||||
task:set_milter_reply({
|
task:set_milter_reply({
|
||||||
add_headers = {['X-Moo-Tag'] = 'YES'}
|
add_headers = {['X-Moo-Tag'] = 'YES'}
|
||||||
|
@ -1298,6 +1298,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
|
|||||||
if (isset($_data['tagged_mail_handler']) && $_data['tagged_mail_handler'] == "subject") {
|
if (isset($_data['tagged_mail_handler']) && $_data['tagged_mail_handler'] == "subject") {
|
||||||
try {
|
try {
|
||||||
$redis->hSet('RCPT_WANTS_SUBJECT_TAG', $username, 1);
|
$redis->hSet('RCPT_WANTS_SUBJECT_TAG', $username, 1);
|
||||||
|
$redis->hDel('RCPT_WANTS_SUBFOLDER_TAG', $username);
|
||||||
}
|
}
|
||||||
catch (RedisException $e) {
|
catch (RedisException $e) {
|
||||||
$_SESSION['return'] = array(
|
$_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") {
|
else if (isset($_data['tagged_mail_handler']) && $_data['tagged_mail_handler'] == "subfolder") {
|
||||||
try {
|
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) {
|
catch (RedisException $e) {
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
@ -1322,6 +1324,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
|
|||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
$redis->hDel('RCPT_WANTS_SUBJECT_TAG', $username);
|
$redis->hDel('RCPT_WANTS_SUBJECT_TAG', $username);
|
||||||
|
$redis->hDel('RCPT_WANTS_SUBFOLDER_TAG', $username);
|
||||||
}
|
}
|
||||||
catch (RedisException $e) {
|
catch (RedisException $e) {
|
||||||
$_SESSION['return'] = array(
|
$_SESSION['return'] = array(
|
||||||
@ -2631,11 +2634,10 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
|
|||||||
$_data = $_SESSION['mailcow_cc_username'];
|
$_data = $_SESSION['mailcow_cc_username'];
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$wants_subject_tag = $redis->hGet('RCPT_WANTS_SUBJECT_TAG', $_data);
|
if ($redis->hGet('RCPT_WANTS_SUBJECT_TAG', $_data)) {
|
||||||
if ($wants_subject_tag == 1) {
|
|
||||||
return "subject";
|
return "subject";
|
||||||
}
|
}
|
||||||
elseif ($wants_subject_tag == 2) {
|
elseif ($redis->hGet('RCPT_WANTS_SUBFOLDER_TAG', $_data)) {
|
||||||
return "subfolder";
|
return "subfolder";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user