diff --git a/data/web/admin.php b/data/web/admin.php index a870cd71..5b401243 100644 --- a/data/web/admin.php +++ b/data/web/admin.php @@ -201,7 +201,7 @@ if (!isset($_SESSION['gal']) && $license_cache = $redis->Get('LICENSE_STATUS_CAC - +

Rspamd UI

@@ -655,7 +655,7 @@ if (!isset($_SESSION['gal']) && $license_cache = $redis->Get('LICENSE_STATUS_CAC if (!empty($f2b_data['active_bans'])): foreach ($f2b_data['active_bans'] as $active_bans): ?> -

() - +

() - @@ -1136,7 +1136,7 @@ if (!isset($_SESSION['gal']) && $license_cache = $redis->Get('LICENSE_STATUS_CAC

- +
@@ -1199,6 +1199,7 @@ echo "var log_pagination_size = '". $LOG_PAGINATION_SIZE . "';\n"; add('/web/js/site/admin.js'); +$js_minifier->add('/web/js/presets/rspamd.js'); require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; } else { header('Location: /'); diff --git a/data/web/js/presets/rspamd.js b/data/web/js/presets/rspamd.js new file mode 100644 index 00000000..c3ab9924 --- /dev/null +++ b/data/web/js/presets/rspamd.js @@ -0,0 +1,32 @@ +var rspamdPresets = [ + { + description: lang.rsettings_preset_1, + codeValue: 'priority = 10;\nauthenticated = yes;\napply "default" {\n symbols_enabled = ["DKIM_SIGNED", "RATELIMITED", "RATELIMIT_UPDATE", "RATELIMIT_CHECK", "DYN_RL_CHECK", "HISTORY_SAVE", "MILTER_HEADERS", "ARC_SIGNED"];\n}' + }, + { + description: lang.rsettings_preset_2, + codeValue: 'priority = 10;\nrcpt = "/postmaster@.*/";\nwant_spam = yes;' + } +]; + +var rspamd_presetsElem = document.getElementById("rspamd_presets"); +if (rspamd_presetsElem && rspamdPresets) { + rspamd_presetsElem.innerHTML = ''; + rspamdPresets.forEach(function (item, index) { + var elemID = 'rspamd_preset_' + index; + rspamd_presetsElem.innerHTML += '
  • ' + lang.rsettings_insert_preset.replace('%s', item.description) + '
  • '; + + /* + we need to define 0-timeout here, to prevent dom not be ready. + */ + setTimeout(function () { + document.getElementById(elemID).addEventListener('click', function (e) { + e.preventDefault(); + document.querySelector('form[data-id=rsetting] #adminRspamdSettingsDesc').value = item.description; + document.querySelector('form[data-id=rsetting] #adminRspamdSettingsContent').value = item.codeValue; + return true; + }); + }, 0) + + }); +} diff --git a/data/web/js/presets/sieveMailbox.js b/data/web/js/presets/sieveMailbox.js new file mode 100644 index 00000000..e8548ee6 --- /dev/null +++ b/data/web/js/presets/sieveMailbox.js @@ -0,0 +1,31 @@ +var sieveMailboxPresets = [ + { + description: lang.sieve_preset_1, + codeValue: 'if header :contains "x-attached"\n [".exe",".bat",".js",".com",".cmd",".ini",".dll",".bas",".cpl",".drv",".inf",".sys",".pif",".doc",".docx"] {\n discard;\n stop;\n}' + }, + { + description: lang.sieve_preset_2, + codeValue: 'require ["envelope", "imap4flags"];\nif envelope "from" "mark@me-read.com"\n{\n setflag "\\\\seen";\n}' + } +]; + +var sieve_presetsElem = document.getElementById("sieve_presets"); +if (sieve_presetsElem && sieveMailboxPresets) { + sieve_presetsElem.innerHTML = ''; + sieveMailboxPresets.forEach(function (item, index) { + var elemID = 'sieve_preset_' + index; + sieve_presetsElem.innerHTML += '
  • ' + lang.insert_preset.replace('%s', item.description) + '
  • '; + + /* + we need to define 0-timeout here, to prevent dom not be ready. + */ + setTimeout(function () { + document.getElementById(elemID).addEventListener('click', function (e) { + e.preventDefault(); + document.querySelector('form[data-id=add_filter] #script_desc').value = item.description; + document.querySelector('form[data-id=add_filter] #script_data').value = item.codeValue; + return true; + }); + }, 0) + }); +} diff --git a/data/web/js/site/admin.js b/data/web/js/site/admin.js index 21a513b1..f3007dec 100644 --- a/data/web/js/site/admin.js +++ b/data/web/js/site/admin.js @@ -9,16 +9,6 @@ jQuery(function($){ function humanFileSize(i){if(Math.abs(i)<1024)return i+" B";var B=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],e=-1;do{i/=1024,++e}while(Math.abs(i)>=1024&&eRspamd docs\r\n - Ein Name wird automatisch generiert. Beispielinhalte zur Einsicht stehen nachstehend bereit.", + "rspamd-com_settings": "Ein Name wird automatisch generiert. Beispielinhalte zur Einsicht stehen nachstehend bereit. Siehe auch Rspamd docs", "no_new_rows": "Keine weiteren Zeilen vorhanden", "additional_rows": " zusätzliche Zeilen geladen", "private_key": "Private Key", @@ -647,7 +647,11 @@ "alias_domain_backupmx": "Alias-Domain für Relay-Domain inaktiv", "add_domain_record_first": "Bitte zuerst eine Domain hinzufügen", "no": "✕", - "yes": "✓" + "yes": "✓", + "insert_preset": "Beispiel \"%s\" laden", + "sieve_preset_header": "Beispielinhalte zur Einsicht stehen nachstehend bereit. Siehe auch Wikipedia.", + "sieve_preset_1": "E-Mails mit potenziell gefährlichen Dateitypen abweisen", + "sieve_preset_2": "E-Mail eines bestimmten Absenders immer als gelesen markieren" }, "edit": { "sogo_visible": "Alias in SOGo sichtbar", diff --git a/data/web/lang/lang.en.json b/data/web/lang/lang.en.json index 3837f3e5..62559386 100644 --- a/data/web/lang/lang.en.json +++ b/data/web/lang/lang.en.json @@ -311,7 +311,7 @@ "spamfilter": "Spam filter", "domain": "Domain", "domain_s": "Domain/s", - "rspamd-com_settings": "Rspamd docs\r\n - A setting name will be auto-generated, please see the example presets below.", + "rspamd-com_settings": "A setting name will be auto-generated, please see the example presets below. For more details see Rspamd docs", "no_new_rows": "No further rows available", "queue_manager": "Queue manager", "additional_rows": " additional rows were added", @@ -646,7 +646,11 @@ "recipient_map_new": "New recipient", "add_recipient_map_entry": "Add recipient map", "mailbox_defquota": "Default mailbox size", - "alias_domain_backupmx": "Alias domain inactive for relay domain" + "alias_domain_backupmx": "Alias domain inactive for relay domain", + "insert_preset": "Insert example preset \"%s\"", + "sieve_preset_header": "Please see the example presets below. For more details see Wikipedia.", + "sieve_preset_1": "Discard mail with probable dangerous file types", + "sieve_preset_2": "Always mark the e-mail of a specific sender as seen" }, "edit": { "sogo_visible": "Alias is visible in SOGo", diff --git a/data/web/mailbox.php b/data/web/mailbox.php index fc2fc9c6..e71372ad 100644 --- a/data/web/mailbox.php +++ b/data/web/mailbox.php @@ -360,6 +360,7 @@ echo "var ALLOW_ADMIN_EMAIL_LOGIN = " . $ALLOW_ADMIN_EMAIL_LOGIN . ";\n"; add('/web/js/site/mailbox.js'); +$js_minifier->add('/web/js/presets/sieveMailbox.js'); $js_minifier->add('/web/js/site/pwgen.js'); require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; } diff --git a/data/web/modals/admin.php b/data/web/modals/admin.php index ae23d63a..d0167700 100644 --- a/data/web/modals/admin.php +++ b/data/web/modals/admin.php @@ -41,8 +41,7 @@ if (!isset($_SESSION['mailcow_cc_role'])) {

    -
    - +
      diff --git a/data/web/modals/mailbox.php b/data/web/modals/mailbox.php index fcc53ab2..7cebaa5c 100644 --- a/data/web/modals/mailbox.php +++ b/data/web/modals/mailbox.php @@ -397,7 +397,7 @@ if (!isset($_SESSION['mailcow_cc_role'])) { ?> - +
      @@ -586,7 +586,7 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
      - +
      @@ -610,6 +610,8 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
      + +