diff --git a/data/web/js/presets/rspamd.js b/data/web/js/presets/rspamd.js
index bc0f6338..c16114d0 100644
--- a/data/web/js/presets/rspamd.js
+++ b/data/web/js/presets/rspamd.js
@@ -1,36 +1,34 @@
-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;'
- }
-];
-/*
-TODO: aus API holen:
-/api/v1/get/rspamd/sieve/
- */
-
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)
+if (rspamd_presetsElem) {
+ $.ajax({
+ dataType: 'json',
+ url: '/api/v1/get/presets/admin-rspamd',
+ jsonp: false,
+ complete: function (data) {
+ if (data.responseText !== '{}') {
+ var rspamdPresets = JSON.parse(data.responseText);
+ if (rspamdPresets) {
+ rspamd_presetsElem.innerHTML = '';
+ rspamdPresets.forEach(function (item, index) {
+ var elemID = 'rspamd_preset_' + index;
+ rspamd_presetsElem.innerHTML += '' + lang.rsettings_insert_preset.replace('%s', item.headline) + '';
+
+ /*
+ 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.headline;
+ document.querySelector('form[data-id=rsetting] #adminRspamdSettingsContent').value = item.content;
+ return true;
+ });
+ }, 0);
+ });
+ }
+ }
+ }
});
}
diff --git a/data/web/js/presets/sieveMailbox.js b/data/web/js/presets/sieveMailbox.js
index f706fc07..05eaa2c5 100644
--- a/data/web/js/presets/sieveMailbox.js
+++ b/data/web/js/presets/sieveMailbox.js
@@ -1,35 +1,34 @@
-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}'
- }
-];
-/*
-TODO: aus API holen:
-/api/v1/get/rspamd/sieve/
- */
-
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)
+if (sieve_presetsElem) {
+ $.ajax({
+ dataType: 'json',
+ url: '/api/v1/get/presets/mailbox-sieve',
+ jsonp: false,
+ complete: function (data) {
+ if (data.responseText !== '{}') {
+ var sieveMailboxPresets = JSON.parse(data.responseText);
+
+ if (sieveMailboxPresets) {
+ sieve_presetsElem.innerHTML = '';
+ sieveMailboxPresets.forEach(function (item, index) {
+ var elemID = 'sieve_preset_' + index;
+ sieve_presetsElem.innerHTML += '' + lang.insert_preset.replace('%s', item.headline) + '';
+
+ /*
+ 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.headline;
+ document.querySelector('form[data-id=add_filter] #script_data').value = item.content;
+ return true;
+ });
+ }, 0);
+ });
+ }
+ }
+ }
});
}