mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03:00
Improved Sieve code and added rfc5435
This commit is contained in:
parent
f453abf149
commit
b3c1723c5c
10 changed files with 165 additions and 65 deletions
123
dev/Sieve/Extensions/rfc5435.js
Normal file
123
dev/Sieve/Extensions/rfc5435.js
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
/**
|
||||
* https://tools.ietf.org/html/rfc5435
|
||||
*/
|
||||
|
||||
import {
|
||||
GrammarCommand,
|
||||
GrammarNumber,
|
||||
GrammarQuotedString,
|
||||
GrammarStringList,
|
||||
GrammarTest
|
||||
} from 'Sieve/Grammar';
|
||||
|
||||
/**
|
||||
* https://datatracker.ietf.org/doc/html/rfc5435#section-3
|
||||
*/
|
||||
export class NotifyCommand extends GrammarCommand
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
this._method = new GrammarQuotedString;
|
||||
this._from = new GrammarQuotedString;
|
||||
this._importance = new GrammarNumber;
|
||||
this.options = new GrammarStringList;
|
||||
this._message = new GrammarQuotedString;
|
||||
}
|
||||
|
||||
get method() { return this._method.value; }
|
||||
get from() { return this._from.value; }
|
||||
get importance() { return this._importance.value; }
|
||||
get message() { return this._message.value; }
|
||||
|
||||
set method(str) { this._method.value = str; }
|
||||
set from(str) { this._from.value = str; }
|
||||
set importance(int) { this._importance.value = int; }
|
||||
set message(str) { this._message.value = str; }
|
||||
|
||||
get require() { return 'enotify'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
let result = 'notify';
|
||||
if (this._from.value) {
|
||||
result += ' :from ' + this._from;
|
||||
}
|
||||
if (0 < this._importance.value) {
|
||||
result += ' :importance ' + this._importance;
|
||||
}
|
||||
if (this.options.length) {
|
||||
result += ' :options ' + this.options;
|
||||
}
|
||||
if (this._message.value) {
|
||||
result += ' :message ' + this._message;
|
||||
}
|
||||
return result + ' ' + this._method;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
{
|
||||
this._method.value = args.pop().value; // GrammarQuotedString
|
||||
args.forEach((arg, i) => {
|
||||
if (':options' === args[i-1]) {
|
||||
this.options = arg; // GrammarStringList
|
||||
} else if (':' === args[i-1][0]) {
|
||||
// :from, :importance, :message
|
||||
this[args[i-1].replace(':','_')].value = arg.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* https://datatracker.ietf.org/doc/html/rfc5435#section-4
|
||||
*/
|
||||
export class ValidNotifyMethodTest extends GrammarTest
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
this.notification_uris = new GrammarStringList;
|
||||
}
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'valid_notify_method ' + this.notification_uris;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
{
|
||||
this.notification_uris = args.pop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* https://datatracker.ietf.org/doc/html/rfc5435#section-5
|
||||
*/
|
||||
export class NotifyMethodCapabilityTest extends GrammarTest
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
this.notification_uri = new GrammarQuotedString;
|
||||
this.notification_capability = new GrammarQuotedString;
|
||||
this.key_list = new GrammarStringList;
|
||||
}
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'valid_notify_method '
|
||||
+ (this.comparator ? ' :comparator ' + this.comparator : '')
|
||||
+ (this.match_type ? ' ' + this.match_type : '')
|
||||
+ this.notification_uri
|
||||
+ this.notification_capability
|
||||
+ this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(args)
|
||||
{
|
||||
this.key_list = args.pop();
|
||||
this.notification_capability = args.pop();
|
||||
this.notification_uri = args.pop();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue