Always allow raw editing of Sieve scripts

This commit is contained in:
djmaze 2021-01-21 10:00:12 +01:00
parent 3ed7b53f68
commit 14ba459d46
20 changed files with 59 additions and 211 deletions

View file

@ -3,6 +3,8 @@ import ko from 'ko';
import { AbstractModel } from 'Knoin/AbstractModel';
import { FilterModel } from 'Model/Filter';
const SIEVE_FILE_NAME = 'rainloop.user';
// collectionToFileString
function filtersToSieveScript(filters)
{
@ -311,7 +313,7 @@ class SieveScriptModel extends AbstractModel
* Only 'rainloop.user' script supports filters
*/
allowFilters() {
return 'rainloop.user' === this.name();
return SIEVE_FILE_NAME === this.name();
}
/**
@ -331,7 +333,7 @@ class SieveScriptModel extends AbstractModel
} else {
script.filters([]);
}
script.canBeDeleted(0 !== json.name.indexOf('rainloop.user'));
script.canBeDeleted(SIEVE_FILE_NAME !== json.name);
script.exists(true);
script.hasChanges(false);
}

View file

@ -161,83 +161,47 @@ class RemoteAdminFetch extends AbstractFetchRemote {
});
}
createOrUpdateDomain(
fCallback,
bCreate,
sName,
sIncHost,
iIncPort,
sIncSecure,
bIncShortLogin,
bUseSieve,
sSieveAllowRaw,
sSieveHost,
iSievePort,
sSieveSecure,
sOutHost,
iOutPort,
sOutSecure,
bOutShortLogin,
bOutAuth,
bOutPhpMail,
sWhiteList
) {
createOrUpdateDomain(fCallback, oDomain) {
this.defaultRequest(fCallback, 'AdminDomainSave', {
Create: bCreate ? 1 : 0,
Name: sName,
Create: oDomain.edit() ? 0 : 1,
Name: oDomain.name(),
IncHost: sIncHost,
IncPort: iIncPort,
IncSecure: sIncSecure,
IncShortLogin: bIncShortLogin ? 1 : 0,
IncHost: oDomain.imapServer(),
IncPort: oDomain.imapPort(),
IncSecure: oDomain.imapSecure(),
IncShortLogin: oDomain.imapShortLogin() ? 1 : 0,
UseSieve: bUseSieve ? 1 : 0,
SieveAllowRaw: sSieveAllowRaw ? 1 : 0,
SieveHost: sSieveHost,
SievePort: iSievePort,
SieveSecure: sSieveSecure,
UseSieve: oDomain.useSieve() ? 1 : 0,
SieveHost: oDomain.sieveServer(),
SievePort: oDomain.sievePort(),
SieveSecure: oDomain.sieveSecure(),
OutHost: sOutHost,
OutPort: iOutPort,
OutSecure: sOutSecure,
OutShortLogin: bOutShortLogin ? 1 : 0,
OutAuth: bOutAuth ? 1 : 0,
OutUsePhpMail: bOutPhpMail ? 1 : 0,
OutHost: oDomain.smtpServer(),
OutPort: oDomain.smtpPort(),
OutSecure: oDomain.smtpSecure(),
OutShortLogin: oDomain.smtpShortLogin() ? 1 : 0,
OutAuth: oDomain.smtpAuth() ? 1 : 0,
OutUsePhpMail: oDomain.smtpPhpMail() ? 1 : 0,
WhiteList: sWhiteList
WhiteList: oDomain.whiteList()
});
}
testConnectionForDomain(
fCallback,
sName,
sIncHost,
iIncPort,
sIncSecure,
bUseSieve,
sSieveHost,
iSievePort,
sSieveSecure,
sOutHost,
iOutPort,
sOutSecure,
bOutAuth,
bOutPhpMail
) {
testConnectionForDomain(fCallback, oDomain) {
this.defaultRequest(fCallback, 'AdminDomainTest', {
Name: sName,
IncHost: sIncHost,
IncPort: iIncPort,
IncSecure: sIncSecure,
UseSieve: bUseSieve ? 1 : 0,
SieveHost: sSieveHost,
SievePort: iSievePort,
SieveSecure: sSieveSecure,
OutHost: sOutHost,
OutPort: iOutPort,
OutSecure: sOutSecure,
OutAuth: bOutAuth ? 1 : 0,
OutUsePhpMail: bOutPhpMail ? 1 : 0
Name: oDomain.name(),
IncHost: oDomain.imapServer(),
IncPort: oDomain.imapPort(),
IncSecure: oDomain.imapSecure(),
UseSieve: oDomain.useSieve() ? 1 : 0,
SieveHost: oDomain.sieveServer(),
SievePort: oDomain.sievePort(),
SieveSecure: oDomain.sieveSecure(),
OutHost: oDomain.smtpServer(),
OutPort: oDomain.smtpPort(),
OutSecure: oDomain.smtpSecure(),
OutAuth: oDomain.smtpAuth() ? 1 : 0,
OutUsePhpMail: oDomain.smtpPhpMail() ? 1 : 0
});
}

View file

@ -44,7 +44,6 @@ class DomainPopupView extends AbstractViewNext {
imapSecure: ServerSecure.None,
imapShortLogin: false,
useSieve: false,
sieveAllowRaw: false,
sieveServer: '',
sievePort: '4190',
sieveSecure: ServerSecure.None,
@ -174,28 +173,7 @@ class DomainPopupView extends AbstractViewNext {
this.saving(true);
Remote.createOrUpdateDomain(
this.onDomainCreateOrSaveResponse.bind(this),
!this.edit(),
this.name(),
this.imapServer(),
pInt(this.imapPort()),
this.imapSecure(),
this.imapShortLogin(),
this.useSieve(),
this.sieveAllowRaw(),
this.sieveServer(),
pInt(this.sievePort()),
this.sieveSecure(),
this.smtpServer(),
pInt(this.smtpPort()),
this.smtpSecure(),
this.smtpShortLogin(),
this.smtpAuth(),
this.smtpPhpMail(),
this.whiteList()
this
);
}
@ -211,22 +189,7 @@ class DomainPopupView extends AbstractViewNext {
Remote.testConnectionForDomain(
this.onTestConnectionResponse.bind(this),
this.name(),
this.imapServer(),
pInt(this.imapPort()),
this.imapSecure(),
this.useSieve(),
this.sieveServer(),
pInt(this.sievePort()),
this.sieveSecure(),
this.smtpServer(),
pInt(this.smtpPort()),
this.smtpSecure(),
this.smtpAuth(),
this.smtpPhpMail()
this
);
}
@ -336,7 +299,6 @@ class DomainPopupView extends AbstractViewNext {
this.imapSecure(oDomain.IncSecure);
this.imapShortLogin(!!oDomain.IncShortLogin);
this.useSieve(!!oDomain.UseSieve);
this.sieveAllowRaw(!!oDomain.SieveAllowRaw);
this.sieveServer(oDomain.SieveHost);
this.sievePort('' + pInt(oDomain.SievePort));
this.sieveSecure(oDomain.SieveSecure);
@ -371,7 +333,6 @@ class DomainPopupView extends AbstractViewNext {
this.imapShortLogin(false);
this.useSieve(false);
this.sieveAllowRaw(false);
this.sieveServer('');
this.sievePort('4190');
this.sieveSecure(ServerSecure.None);

View file

@ -25,8 +25,6 @@ class FilterPopupView extends AbstractViewNext {
selectedFolderValue: ''
});
this.modules = SieveStore.capa;
this.fTrueCallback = null;
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
@ -34,15 +32,13 @@ class FilterPopupView extends AbstractViewNext {
this.selectedFolderValue.subscribe(() => this.filter() && this.filter().actionValueError(false));
this.actionTypeOptions = ko.observableArray([]);
this.fieldOptions = ko.observableArray([]);
this.typeOptions = ko.observableArray([]);
this.typeOptionsSize = ko.observableArray([]);
this.typeOptionsBody = ko.observableArray([]);
['actionTypeOptions','fieldOptions','typeOptions','typeOptionsSize','typeOptionsBody'].forEach(
key => this[key] = ko.observableArray([])
);
initOnStartOrLangChange(this.populateOptions.bind(this));
this.modules.subscribe(this.populateOptions, this);
SieveStore.capa.subscribe(this.populateOptions, this);
}
@command()
@ -84,7 +80,7 @@ class FilterPopupView extends AbstractViewNext {
// this.actionTypeOptions.push({'id': FiltersAction.None,
// 'name': i18n('POPUPS_FILTER/SELECT_ACTION_NONE')});
const modules = this.modules();
const modules = SieveStore.capa();
if (modules) {
if (modules.includes('imap4flags')) {
this.allowMarkAsRead(true);