Skip to content

Commit

Permalink
add new settings to set default values for customer antispam options …
Browse files Browse the repository at this point in the history
…for new email addresses (settings advanced-mode)

Signed-off-by: Michael Kaufmann <[email protected]>
  • Loading branch information
d00p committed Nov 20, 2024
1 parent 4f11473 commit 13aa07e
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 17 deletions.
45 changes: 45 additions & 0 deletions actions/admin/settings/180.antispam.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,51 @@
'save_method' => 'storeSettingField',
'required_otp' => true
],
'antispam_default_bypass_spam' => [
'label' => lng('antispam.default_bypass_spam'),
'settinggroup' => 'antispam',
'varname' => 'default_bypass_spam',
'type' => 'select',
'default' => 2,
'select_var' => [
1 => lng('antispam.default_select.on_changeable'),
2 => lng('antispam.default_select.off_changeable'),
3 => lng('antispam.default_select.on_unchangeable'),
4 => lng('antispam.default_select.off_unchangeable'),
],
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'antispam_default_spam_rewrite_subject' => [
'label' => lng('antispam.default_spam_rewrite_subject'),
'settinggroup' => 'antispam',
'varname' => 'default_spam_rewrite_subject',
'type' => 'select',
'default' => 1,
'select_var' => [
1 => lng('antispam.default_select.on_changeable'),
2 => lng('antispam.default_select.off_changeable'),
3 => lng('antispam.default_select.on_unchangeable'),
4 => lng('antispam.default_select.off_unchangeable'),
],
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'antispam_default_policy_greylist' => [
'label' => lng('antispam.default_policy_greylist'),
'settinggroup' => 'antispam',
'varname' => 'default_policy_greylist',
'type' => 'select',
'default' => 1,
'select_var' => [
1 => lng('antispam.default_select.on_changeable'),
2 => lng('antispam.default_select.off_changeable'),
3 => lng('antispam.default_select.on_unchangeable'),
4 => lng('antispam.default_select.off_unchangeable'),
],
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'antispam_dkim_keylength' => [
'label' => lng('antispam.dkim_keylength'),
'settinggroup' => 'antispam',
Expand Down
5 changes: 4 additions & 1 deletion install/froxlor.sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@
('antispam', 'config_file', '/etc/rspamd/local.d/froxlor_settings.conf'),
('antispam', 'reload_command', 'service rspamd restart'),
('antispam', 'dkim_keylength', '1024'),
('antispam', 'default_bypass_spam', '2'),
('antispam', 'default_spam_rewrite_subject', '1'),
('antispam', 'default_policy_greylist', '1'),
('admin', 'show_news_feed', '0'),
('admin', 'show_version_login', '0'),
('admin', 'show_version_footer', '0'),
Expand Down Expand Up @@ -731,7 +734,7 @@
('panel', 'settings_mode', '0'),
('panel', 'menu_collapsed', '1'),
('panel', 'version', '2.2.5'),
('panel', 'db_version', '202409280');
('panel', 'db_version', '202411200');
DROP TABLE IF EXISTS `panel_tasks`;
Expand Down
11 changes: 11 additions & 0 deletions install/updates/froxlor/update_2.2.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,14 @@
Update::showUpdateStep("Updating from 2.2.4 to 2.2.5", false);
Froxlor::updateToVersion('2.2.5');
}

if (Froxlor::isDatabaseVersion('202409280')) {

Update::showUpdateStep("Adding new antispam settings");
Settings::AddNew("antispam.default_bypass_spam", "2");
Settings::AddNew("antispam.default_spam_rewrite_subject", "1");
Settings::AddNew("antispam.default_policy_greylist", "1");
Update::lastStepStatus(0);

Froxlor::updateToDbVersion('202411200');
}
50 changes: 38 additions & 12 deletions lib/Froxlor/Api/Commands/Emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ class Emails extends ApiCommand implements ResourceEntity
* @param float $spam_tag_level
* optional, score which is required to tag emails as spam, default: 7.0
* @param bool $rewrite_subject
* optional, whether to add ***SPAM*** to the email's subject if applicable, default true
* optional, whether to add ***SPAM*** to the email's subject if applicable, default: [antispam.default_spam_rewrite_subject]
* @param float $spam_kill_level
* optional, score which is required to discard emails, default: 14.0
* @param boolean $bypass_spam
* optional, disable spam-filter entirely, default: no
* optional, disable spam-filter entirely, default: [antispam.default_bypass_spam]
* @param boolean $policy_greylist
* optional, enable grey-listing, default: yes
* optional, enable grey-listing, default: [antispam.default_policy_greylist]
* @param boolean $iscatchall
* optional, make this address a catchall address, default: no
* @param int $customerid
Expand All @@ -87,13 +87,26 @@ public function add()

// parameters
$spam_tag_level = $this->getParam('spam_tag_level', true, '7.0');
$rewrite_subject = $this->getBoolParam('rewrite_subject', true, 1);
$spam_kill_level = $this->getUlParam('spam_kill_level', 'spam_kill_level_ul', true, '14.0');
$bypass_spam = $this->getBoolParam('bypass_spam', true, 0);
$policy_greylist = $this->getBoolParam('policy_greylist', true, 1);
$iscatchall = $this->getBoolParam('iscatchall', true, 0);
$description = $this->getParam('description', true, '');

if ((int)Settings::Get('antispam.default_spam_rewrite_subject') <= 2) {
$rewrite_subject = $this->getBoolParam('rewrite_subject', true, (int)Settings::Get('antispam.default_spam_rewrite_subject') == 1 ? 1 : 0);
} else {
$rewrite_subject = (int)Settings::Get('antispam.default_spam_rewrite_subject') == 3 ? 1 : 0;
}
if ((int)Settings::Get('antispam.default_bypass_spam') <= 2) {
$bypass_spam = $this->getBoolParam('bypass_spam', true, (int)Settings::Get('antispam.default_bypass_spam') == 1 ? 1 : 0);
} else {
$bypass_spam = (int)Settings::Get('antispam.default_bypass_spam') == 3 ? 1 : 0;
}
if ((int)Settings::Get('antispam.default_policy_greylist') <= 2) {
$policy_greylist = $this->getBoolParam('policy_greylist', true, (int)Settings::Get('antispam.default_policy_greylist') == 1 ? 1 : 0);
} else {
$policy_greylist = (int)Settings::Get('antispam.default_policy_greylist') == 3 ? 1 : 0;
}

// validation
$idna_convert = new IdnaWrapper();
if (substr($domain, 0, 4) != 'xn--') {
Expand Down Expand Up @@ -258,13 +271,13 @@ public function get()
* @param float $spam_tag_level
* optional, score which is required to tag emails as spam, default: 7.0
* @param bool $rewrite_subject
* optional, whether to add ***SPAM*** to the email's subject if applicable, default true
* optional, whether to add ***SPAM*** to the email's subject if applicable, default: [antispam.default_spam_rewrite_subject]
* @param float $spam_kill_level
* optional, score which is required to discard emails, default: 14.0
* @param boolean $bypass_spam
* optional, disable spam-filter entirely, default: no
* optional, disable spam-filter entirely, default: [antispam.default_bypass_spam]
* @param boolean $policy_greylist
* optional, enable grey-listing, default: yes
* optional, enable grey-listing, default: [antispam.default_policy_greylist]
* @param boolean $iscatchall
* optional
* @param string $description
Expand Down Expand Up @@ -292,13 +305,26 @@ public function update()

// parameters
$spam_tag_level = $this->getParam('spam_tag_level', true, $result['spam_tag_level']);
$rewrite_subject = $this->getBoolParam('rewrite_subject', true, $result['rewrite_subject']);
$spam_kill_level = $this->getUlParam('spam_kill_level', 'spam_kill_level_ul', true, $result['spam_kill_level']);
$bypass_spam = $this->getBoolParam('bypass_spam', true, $result['bypass_spam']);
$policy_greylist = $this->getBoolParam('policy_greylist', true, $result['policy_greylist']);
$iscatchall = $this->getBoolParam('iscatchall', true, $result['iscatchall']);
$description = $this->getParam('description', true, $result['description']);

if ((int)Settings::Get('antispam.default_spam_rewrite_subject') <= 2) {
$rewrite_subject = $this->getBoolParam('rewrite_subject', true, $result['rewrite_subject']);
} else {
$rewrite_subject = (int)Settings::Get('antispam.default_spam_rewrite_subject') == 3 ? 1 : 0;
}
if ((int)Settings::Get('antispam.default_bypass_spam') <= 2) {
$bypass_spam = $this->getBoolParam('bypass_spam', true, $result['bypass_spam']);
} else {
$bypass_spam = (int)Settings::Get('antispam.default_bypass_spam') == 3 ? 1 : 0;
}
if ((int)Settings::Get('antispam.default_policy_greylist') <= 2) {
$policy_greylist = $this->getBoolParam('policy_greylist', true, $result['policy_greylist']);
} else {
$policy_greylist = (int)Settings::Get('antispam.default_policy_greylist') == 3 ? 1 : 0;
}

// if enabling catchall is not allowed by settings, we do not need
// to run update()
if ($iscatchall && $result['iscatchall'] == 0 && Settings::Get('catchall.catchall_enabled') != '1') {
Expand Down
2 changes: 1 addition & 1 deletion lib/Froxlor/Froxlor.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class Froxlor
const VERSION = '2.2.5';

// Database version (YYYYMMDDC where C is a daily counter)
const DBVERSION = '202409280';
const DBVERSION = '202411200';

// Distribution branding-tag (used for Debian etc.)
const BRANDING = '';
Expand Down
6 changes: 3 additions & 3 deletions lib/formfields/customer/email/formfield.emails_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
'checked' => (int)$result['iscatchall'],
],
'bypass_spam' => [
'visible' => Settings::Get('antispam.activated') == '1',
'visible' => Settings::Get('antispam.activated') == '1' && (int)Settings::Get('antispam.default_bypass_spam') <= 2,
'label' => lng('antispam.bypass_spam'),
'type' => 'checkbox',
'value' => '1',
Expand All @@ -112,7 +112,7 @@
'value' => $result['spam_tag_level'],
],
'spam_rewrite_subject' => [
'visible' => Settings::Get('antispam.activated') == '1',
'visible' => Settings::Get('antispam.activated') == '1' && (int)Settings::Get('antispam.default_spam_rewrite_subject') <= 2,
'label' => lng('antispam.rewrite_subject'),
'type' => 'checkbox',
'value' => '1',
Expand All @@ -127,7 +127,7 @@
'value' => $result['spam_kill_level']
],
'policy_greylist' => [
'visible' => Settings::Get('antispam.activated') == '1',
'visible' => Settings::Get('antispam.activated') == '1' && (int)Settings::Get('antispam.default_policy_greylist') <= 2,
'label' => lng('antispam.policy_greylist'),
'type' => 'checkbox',
'value' => '1',
Expand Down
18 changes: 18 additions & 0 deletions lng/de.lng.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,24 @@
'required_spf_dns' => 'Erforderlicher SPF DNS Eintrag',
'required_dmarc_dns' => 'Erforderlicher DMARC DNS Eintrag',
'required_dkim_dns' => 'Erforderlicher DKIM DNS Eintrag',
'default_select' => [
'on_changeable' => 'Aktiviert, einstellbar',
'off_changeable' => 'Deaktiviert, einstellbar',
'on_unchangeable' => 'Aktiviert, nicht einstellbar',
'off_unchangeable' => 'Deaktiviert, nicht einstellbar',
],
'default_bypass_spam' => [
'title' => 'Standardwert: Spamfilter umgehen',
'description' => 'Wählen, ob bei neuen E-Mail-Konten "Spamfilter umgehen" standardmäßig aktiviert ist und ob diese Einstellung vom Kunden angepasst werden kann.<br/>Standard: Deaktiviert, einstellbar'
],
'default_spam_rewrite_subject' => [
'title' => 'Standardwert: Betreff ändern',
'description' => 'Wählen, ob bei neuen E-Mail-Konten "Betreff ändern" standardmäßig aktiviert ist und ob diese Einstellung vom Kunden angepasst werden kann.<br/>Standard: Aktiviert, einstellbar'
],
'default_policy_greylist' => [
'title' => 'Standardwert: Verwende greylisting',
'description' => 'Wählen, ob bei neuen E-Mail-Konten "Verwende greylisting" standardmäßig aktiviert ist und ob diese Einstellung vom Kunden angepasst werden kann.<br/>Standard: Aktiviert, einstellbar'
],
],
'dns' => [
'destinationip' => 'Domain-IP-Adresse(n)',
Expand Down
18 changes: 18 additions & 0 deletions lng/en.lng.php
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,24 @@
'required_spf_dns' => 'Required SPF DNS entry',
'required_dmarc_dns' => 'Required DMARC DNS entry',
'required_dkim_dns' => 'Required DKIM DNS entry',
'default_select' => [
'on_changeable' => 'Activated, adjustable',
'off_changeable' => 'Deactivated, adjustable',
'on_unchangeable' => 'Activated, not adjustable',
'off_unchangeable' => 'Deactivated, not adjustable',
],
'default_bypass_spam' => [
'title' => 'Bypass spamfilter default value',
'description' => 'Whether new email accounts have "Bypass spamfilter" activated by default and whether this setting is adjustable by the customer.<br/>Default: Deactivated, adjustable'
],
'default_spam_rewrite_subject' => [
'title' => 'Rewrite subject default value',
'description' => 'Whether new email accounts have "Rewrite subject" activated by default and whether this setting is adjustable by the customer.<br/>Default: Activated, adjustable'
],
'default_policy_greylist' => [
'title' => 'Use greylisting default value',
'description' => 'Whether new email accounts have "Use greylisting" activated by default and whether this setting is adjustable by the customer.<br/>Default: Activated, adjustable'
],
],
'dns' => [
'destinationip' => 'Domain IP(s)',
Expand Down

0 comments on commit 13aa07e

Please sign in to comment.