diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php
index 045fa011..21676c64 100644
--- a/data/web/inc/functions.mailbox.inc.php
+++ b/data/web/inc/functions.mailbox.inc.php
@@ -1151,13 +1151,21 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
return false;
}
foreach ($usernames as $username) {
+ if ($_data['spam_score'] == "default") {
+ $stmt = $pdo->prepare("DELETE FROM `filterconf` WHERE `object` = :username
+ AND (`option` = 'lowspamlevel' OR `option` = 'highspamlevel')");
+ $stmt->execute(array(
+ ':username' => $username
+ ));
+ continue;
+ }
$lowspamlevel = explode(',', $_data['spam_score'])[0];
$highspamlevel = explode(',', $_data['spam_score'])[1];
if (!is_numeric($lowspamlevel) || !is_numeric($highspamlevel)) {
$_SESSION['return'][] = array(
'type' => 'danger',
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
- 'msg' => 'access_denied'
+ 'msg' => 'Invalid spam score, format must be "1,2" where first is low and second is high spam value.'
);
continue;
}
@@ -2455,7 +2463,47 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
return $syncjobdata;
break;
case 'spam_score':
- $default = "5, 15";
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_UNIX_SOCKET_PATH, '/var/lib/rspamd/rspamd.sock');
+ curl_setopt($curl, CURLOPT_URL,"http://rspamd/actions");
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+ $default_actions = curl_exec($curl);
+ if (!curl_errno($curl)) {
+ $data_array = json_decode($default_actions, true);
+ curl_close($curl);
+ foreach ($data_array as $data) {
+ if ($data['action'] == 'reject') {
+ $reject = $data['value'];
+ continue;
+ }
+ elseif ($data['action'] == 'add header') {
+ $add_header = $data['value'];
+ continue;
+ }
+ }
+ if (empty($add_header) || empty($reject)) {
+ // Assume default, set warning
+ $default = "5, 15";
+ $_SESSION['return'][] = array(
+ 'type' => 'warning',
+ 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
+ 'msg' => 'Could not determine servers default spam score, assuming default'
+ );
+ }
+ else {
+ $default = $add_header . ', ' . $reject;
+ }
+ }
+ else {
+ // Assume default, set warning
+ $default = "5, 15";
+ $_SESSION['return'][] = array(
+ 'type' => 'warning',
+ 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
+ 'msg' => 'Could not determine servers default spam score, assuming default'
+ );
+ }
+ curl_close($curl);
$policydata = array();
if (isset($_data) && filter_var($_data, FILTER_VALIDATE_EMAIL)) {
if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $_data)) {
diff --git a/data/web/lang/lang.de.php b/data/web/lang/lang.de.php
index 5c0c6412..8b63c45e 100644
--- a/data/web/lang/lang.de.php
+++ b/data/web/lang/lang.de.php
@@ -598,6 +598,7 @@ $lang['admin']['reset_default'] = "Zurücksetzen auf Standard";
$lang['admin']['merged_vars_hint'] = 'Ausgegraute Reihen wurden aus der Datei vars.(local.)inc.php
gelesen und können hier nicht verändert werden.';
$lang['edit']['spam_score'] = "Einen benutzerdefiniterten Spam-Score festlegen";
+$lang['user']['spam_score_reset'] = "Auf Server-Standard zurücksetzen";
$lang['edit']['spam_policy'] = "Hinzufügen und Entfernen von Einträgen in White- und Blacklists";
$lang['edit']['spam_alias'] = "Anpassen temporärer Alias-Adressen";
diff --git a/data/web/lang/lang.en.php b/data/web/lang/lang.en.php
index 904d87cb..9cdf15da 100644
--- a/data/web/lang/lang.en.php
+++ b/data/web/lang/lang.en.php
@@ -614,6 +614,7 @@ $lang['mailbox']['status'] = "Status";
$lang['mailbox']['running'] = "Running";
$lang['edit']['spam_score'] = "Set a custom spam score";
+$lang['user']['spam_score_reset'] = "Reset to server default";
$lang['edit']['spam_policy'] = "Add or remove items to white-/blacklist";
$lang['edit']['spam_alias'] = "Create or change time limited alias addresses";
diff --git a/data/web/user.php b/data/web/user.php
index bbdd2c6f..1eb5d322 100644
--- a/data/web/user.php
+++ b/data/web/user.php
@@ -305,19 +305,26 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
=$lang['user']['spamfilter_default_score'];?> 5:15
=$lang['user']['spamfilter_hint'];?>