mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Added draft code for handling "require []"
This commit is contained in:
parent
d9865e3a46
commit
43c669e629
8 changed files with 36 additions and 9 deletions
|
|
@ -115,9 +115,10 @@ class FileInto extends Command
|
|||
super('fileinto');
|
||||
// QuotedString / MultiLine
|
||||
this._mailbox = new Grammar.QuotedString();
|
||||
// this.require = 'fileinto';
|
||||
}
|
||||
|
||||
get require() { return 'fileinto'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'fileinto ' + this._mailbox + ';';
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@ class Body extends Grammar.Test
|
|||
this.match_type = ':is',
|
||||
this.body_transform = ''; // :raw, :content <string-list>, :text
|
||||
this.key_list = new Grammar.StringList;
|
||||
// this.require = 'body';
|
||||
}
|
||||
|
||||
get require() { return 'body'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'body'
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ class Vacation extends Grammar.Command
|
|||
':handle' : new Grammar.QuotedString
|
||||
};
|
||||
this.reason = ''; // QuotedString / MultiLine
|
||||
// this.require = 'vacation';
|
||||
}
|
||||
|
||||
get require() { return 'vacation'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
let result = 'vacation';
|
||||
|
|
|
|||
|
|
@ -13,9 +13,10 @@ class Flag extends Grammar.Command
|
|||
super(identifier);
|
||||
this._variablename = new Grammar.QuotedString;
|
||||
this.list_of_flags = new Grammar.StringList;
|
||||
// this.require = 'imap4flags';
|
||||
}
|
||||
|
||||
get require() { return 'imap4flags'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return this.identifier + ' ' + this._variablename + ' ' + this.list_of_flags + ';';
|
||||
|
|
@ -79,9 +80,10 @@ class HasFlag extends Grammar.Test
|
|||
this.match_type = ':is',
|
||||
this.variable_list = new Grammar.StringList;
|
||||
this.list_of_flags = new Grammar.StringList;
|
||||
// this.require = 'imap4flags';
|
||||
}
|
||||
|
||||
get require() { return 'imap4flags'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'hasflag'
|
||||
|
|
|
|||
|
|
@ -15,9 +15,12 @@ class SpamTest extends Grammar.Test
|
|||
this.comparator = 'i;ascii-casemap',
|
||||
this.match_type = ':is',
|
||||
this.value = new Grammar.QuotedString;
|
||||
// this.require = this.percent ? 'spamtestplus' : 'spamtest';
|
||||
}
|
||||
|
||||
// get require() { return this.percent ? 'spamtestplus' : 'spamtest'; }
|
||||
// get require() { return /:value|:count/.test(this.match_type) ? 'relational' : ''; }
|
||||
get require() { return 'spamtestplus'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'spamtest'
|
||||
|
|
@ -56,9 +59,11 @@ class VirusTest extends Grammar.Test
|
|||
this.comparator = 'i;ascii-casemap',
|
||||
this.match_type = ':is',
|
||||
this.value = new Grammar.QuotedString; // 1 - 5
|
||||
// this.require = 'virustest';
|
||||
}
|
||||
|
||||
// get require() { return /:value|:count/.test(this.match_type) ? ['virustest','relational'] : 'virustest'; }
|
||||
get require() { return 'virustest'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'virustest'
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@ class Ereject extends Grammar.Command
|
|||
{
|
||||
super('ereject');
|
||||
this._reason = new Grammar.QuotedString;
|
||||
// this.require = 'ereject';
|
||||
}
|
||||
|
||||
get require() { return 'ereject'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'ereject ' + this._reason + ';';
|
||||
|
|
@ -50,9 +51,10 @@ class Reject extends Grammar.Command
|
|||
{
|
||||
super('reject');
|
||||
this._reason = new Grammar.QuotedString;
|
||||
// this.require = 'reject';
|
||||
}
|
||||
|
||||
get require() { return 'reject'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'reject ' + this._reason + ';';
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ Sieve.parseScript = script => {
|
|||
|
||||
levels = [],
|
||||
command = null,
|
||||
requires = [],
|
||||
args = [];
|
||||
|
||||
const
|
||||
|
|
@ -128,10 +129,19 @@ Sieve.parseScript = script => {
|
|||
}
|
||||
levels.push(new_command);
|
||||
command = new_command;
|
||||
if (command.require) {
|
||||
(Array.isArray(command.require) ? command.require : [command.require])
|
||||
.forEach(string => requires.push(string));
|
||||
}
|
||||
break; }
|
||||
|
||||
// Arguments
|
||||
case T_TAG:
|
||||
/*
|
||||
if (':value' === value || ':count' === value) {
|
||||
requires.push('relational');
|
||||
}
|
||||
*/
|
||||
command
|
||||
? args.push(value.toLowerCase())
|
||||
: error('Tag must be command argument');
|
||||
|
|
@ -179,6 +189,9 @@ Sieve.parseScript = script => {
|
|||
case T_SEMICOLON:
|
||||
command || error('Semicolon not at end of command');
|
||||
pushArgs();
|
||||
if (command instanceof Commands.require) {
|
||||
command.capabilities.forEach(string => requires.push(string.value));
|
||||
}
|
||||
levels.pop();
|
||||
command = levels.last();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ class Envelope extends Test
|
|||
this.key_list = new StringList;
|
||||
}
|
||||
|
||||
get require() { return 'envelope'; }
|
||||
|
||||
toString()
|
||||
{
|
||||
return 'envelope'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue