mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 14:07:04 +03:00
Simplify Sieve Parser and added RFC5235
This commit is contained in:
parent
22964f1fde
commit
d9865e3a46
11 changed files with 308 additions and 92 deletions
90
dev/Sieve/Extensions/rfc5230.js
Normal file
90
dev/Sieve/Extensions/rfc5230.js
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
* https://tools.ietf.org/html/rfc5230
|
||||
*/
|
||||
|
||||
(Sieve => {
|
||||
|
||||
const Grammar = Sieve.Grammar;
|
||||
|
||||
class Vacation extends Grammar.Command
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super('vacation');
|
||||
this.arguments = {
|
||||
':days' : new Grammar.Number,
|
||||
':subject' : new Grammar.QuotedString,
|
||||
':from' : new Grammar.QuotedString,
|
||||
':addresses': new Grammar.StringList,
|
||||
':mime' : false,
|
||||
':handle' : new Grammar.QuotedString
|
||||
};
|
||||
this.reason = ''; // QuotedString / MultiLine
|
||||
// this.require = 'vacation';
|
||||
}
|
||||
|
||||
toString()
|
||||
{
|
||||
let result = 'vacation';
|
||||
if (0 < this.arguments[':days'].value) {
|
||||
result += ' :days ' + this.arguments[':days'];
|
||||
}
|
||||
if (this.arguments[':subject'].length()) {
|
||||
result += ' :subject ' + this.arguments[':subject'];
|
||||
}
|
||||
if (this.arguments[':from'].length()) {
|
||||
result += ' :from ' + this.arguments[':from'];
|
||||
}
|
||||
if (this.arguments[':addresses'].length) {
|
||||
result += ' :addresses ' + this.arguments[':addresses'];
|
||||
}
|
||||
if (this.arguments[':mime']) {
|
||||
result += ' :mime';
|
||||
}
|
||||
if (this.arguments[':handle'].length()) {
|
||||
result += ' :handle ' + this.arguments[':handle'];
|
||||
}
|
||||
return result + ' ' + this.reason;
|
||||
}
|
||||
/*
|
||||
function __get($key)
|
||||
{
|
||||
if ('reason' === $key) {
|
||||
return this.reason;
|
||||
}
|
||||
if (isset(this.arguments[":{$key}"])) {
|
||||
return this.arguments[":{$key}"];
|
||||
}
|
||||
}
|
||||
|
||||
function __set($key, $value)
|
||||
{
|
||||
if ('days' === $key) {
|
||||
this.arguments[":{$key}"] = (int) $value;
|
||||
} else if ('mime' === $key) {
|
||||
this.arguments[":{$key}"] = (bool) $value;
|
||||
} else if ('reason' === $key) {
|
||||
this.reason = (string) $value;
|
||||
} else if ('addresses' !== $key && isset(this.arguments[":{$key}"])) {
|
||||
this.arguments[":{$key}"] = (string) $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function pushArguments(array $args): void
|
||||
{
|
||||
foreach ($args as $i => $arg) {
|
||||
if (\in_array($arg, [':days',':subject',':from',':addresses', ':handle'])) {
|
||||
this.arguments[$arg] = $args[$i+1];
|
||||
} else if (':mime' === $arg) {
|
||||
this.arguments[':mime'] = true;
|
||||
} else if (!isset($args[$i+1])) {
|
||||
this.reason = $arg;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Sieve.Commands.vacation = Vacation;
|
||||
|
||||
})(this.Sieve);
|
||||
Loading…
Add table
Add a link
Reference in a new issue