get sieve and rspamd-filter from new api-point
parent
6ef61cdb8a
commit
fd63fba467
|
@ -1,24 +1,19 @@
|
||||||
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");
|
var rspamd_presetsElem = document.getElementById("rspamd_presets");
|
||||||
if (rspamd_presetsElem && rspamdPresets) {
|
|
||||||
|
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 = '';
|
rspamd_presetsElem.innerHTML = '';
|
||||||
rspamdPresets.forEach(function (item, index) {
|
rspamdPresets.forEach(function (item, index) {
|
||||||
var elemID = 'rspamd_preset_' + index;
|
var elemID = 'rspamd_preset_' + index;
|
||||||
rspamd_presetsElem.innerHTML += '<li><a href="#" class="small" id="' + elemID + '">' + lang.rsettings_insert_preset.replace('%s', item.description) + '</a></li>';
|
rspamd_presetsElem.innerHTML += '<li><a href="#" class="small" id="' + elemID + '">' + lang.rsettings_insert_preset.replace('%s', item.headline) + '</a></li>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
we need to define 0-timeout here, to prevent dom not be ready.
|
we need to define 0-timeout here, to prevent dom not be ready.
|
||||||
|
@ -26,11 +21,14 @@ if (rspamd_presetsElem && rspamdPresets) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
document.getElementById(elemID).addEventListener('click', function (e) {
|
document.getElementById(elemID).addEventListener('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
document.querySelector('form[data-id=rsetting] #adminRspamdSettingsDesc').value = item.description;
|
document.querySelector('form[data-id=rsetting] #adminRspamdSettingsDesc').value = item.headline;
|
||||||
document.querySelector('form[data-id=rsetting] #adminRspamdSettingsContent').value = item.codeValue;
|
document.querySelector('form[data-id=rsetting] #adminRspamdSettingsContent').value = item.content;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}, 0)
|
}, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,19 @@
|
||||||
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");
|
var sieve_presetsElem = document.getElementById("sieve_presets");
|
||||||
if (sieve_presetsElem && sieveMailboxPresets) {
|
|
||||||
|
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 = '';
|
sieve_presetsElem.innerHTML = '';
|
||||||
sieveMailboxPresets.forEach(function (item, index) {
|
sieveMailboxPresets.forEach(function (item, index) {
|
||||||
var elemID = 'sieve_preset_' + index;
|
var elemID = 'sieve_preset_' + index;
|
||||||
sieve_presetsElem.innerHTML += '<li><a href="#" class="small" id="' + elemID + '">' + lang.insert_preset.replace('%s', item.description) + '</a></li>';
|
sieve_presetsElem.innerHTML += '<li><a href="#" class="small" id="' + elemID + '">' + lang.insert_preset.replace('%s', item.headline) + '</a></li>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
we need to define 0-timeout here, to prevent dom not be ready.
|
we need to define 0-timeout here, to prevent dom not be ready.
|
||||||
|
@ -26,10 +21,14 @@ if (sieve_presetsElem && sieveMailboxPresets) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
document.getElementById(elemID).addEventListener('click', function (e) {
|
document.getElementById(elemID).addEventListener('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
document.querySelector('form[data-id=add_filter] #script_desc').value = item.description;
|
document.querySelector('form[data-id=add_filter] #script_desc').value = item.headline;
|
||||||
document.querySelector('form[data-id=add_filter] #script_data').value = item.codeValue;
|
document.querySelector('form[data-id=add_filter] #script_data').value = item.content;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}, 0)
|
}, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue