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');
|
super('fileinto');
|
||||||
// QuotedString / MultiLine
|
// QuotedString / MultiLine
|
||||||
this._mailbox = new Grammar.QuotedString();
|
this._mailbox = new Grammar.QuotedString();
|
||||||
// this.require = 'fileinto';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get require() { return 'fileinto'; }
|
||||||
|
|
||||||
toString()
|
toString()
|
||||||
{
|
{
|
||||||
return 'fileinto ' + this._mailbox + ';';
|
return 'fileinto ' + this._mailbox + ';';
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,10 @@ class Body extends Grammar.Test
|
||||||
this.match_type = ':is',
|
this.match_type = ':is',
|
||||||
this.body_transform = ''; // :raw, :content <string-list>, :text
|
this.body_transform = ''; // :raw, :content <string-list>, :text
|
||||||
this.key_list = new Grammar.StringList;
|
this.key_list = new Grammar.StringList;
|
||||||
// this.require = 'body';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get require() { return 'body'; }
|
||||||
|
|
||||||
toString()
|
toString()
|
||||||
{
|
{
|
||||||
return 'body'
|
return 'body'
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,10 @@ class Vacation extends Grammar.Command
|
||||||
':handle' : new Grammar.QuotedString
|
':handle' : new Grammar.QuotedString
|
||||||
};
|
};
|
||||||
this.reason = ''; // QuotedString / MultiLine
|
this.reason = ''; // QuotedString / MultiLine
|
||||||
// this.require = 'vacation';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get require() { return 'vacation'; }
|
||||||
|
|
||||||
toString()
|
toString()
|
||||||
{
|
{
|
||||||
let result = 'vacation';
|
let result = 'vacation';
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,10 @@ class Flag extends Grammar.Command
|
||||||
super(identifier);
|
super(identifier);
|
||||||
this._variablename = new Grammar.QuotedString;
|
this._variablename = new Grammar.QuotedString;
|
||||||
this.list_of_flags = new Grammar.StringList;
|
this.list_of_flags = new Grammar.StringList;
|
||||||
// this.require = 'imap4flags';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get require() { return 'imap4flags'; }
|
||||||
|
|
||||||
toString()
|
toString()
|
||||||
{
|
{
|
||||||
return this.identifier + ' ' + this._variablename + ' ' + this.list_of_flags + ';';
|
return this.identifier + ' ' + this._variablename + ' ' + this.list_of_flags + ';';
|
||||||
|
|
@ -79,9 +80,10 @@ class HasFlag extends Grammar.Test
|
||||||
this.match_type = ':is',
|
this.match_type = ':is',
|
||||||
this.variable_list = new Grammar.StringList;
|
this.variable_list = new Grammar.StringList;
|
||||||
this.list_of_flags = new Grammar.StringList;
|
this.list_of_flags = new Grammar.StringList;
|
||||||
// this.require = 'imap4flags';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get require() { return 'imap4flags'; }
|
||||||
|
|
||||||
toString()
|
toString()
|
||||||
{
|
{
|
||||||
return 'hasflag'
|
return 'hasflag'
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,12 @@ class SpamTest extends Grammar.Test
|
||||||
this.comparator = 'i;ascii-casemap',
|
this.comparator = 'i;ascii-casemap',
|
||||||
this.match_type = ':is',
|
this.match_type = ':is',
|
||||||
this.value = new Grammar.QuotedString;
|
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()
|
toString()
|
||||||
{
|
{
|
||||||
return 'spamtest'
|
return 'spamtest'
|
||||||
|
|
@ -56,9 +59,11 @@ class VirusTest extends Grammar.Test
|
||||||
this.comparator = 'i;ascii-casemap',
|
this.comparator = 'i;ascii-casemap',
|
||||||
this.match_type = ':is',
|
this.match_type = ':is',
|
||||||
this.value = new Grammar.QuotedString; // 1 - 5
|
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()
|
toString()
|
||||||
{
|
{
|
||||||
return 'virustest'
|
return 'virustest'
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,10 @@ class Ereject extends Grammar.Command
|
||||||
{
|
{
|
||||||
super('ereject');
|
super('ereject');
|
||||||
this._reason = new Grammar.QuotedString;
|
this._reason = new Grammar.QuotedString;
|
||||||
// this.require = 'ereject';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get require() { return 'ereject'; }
|
||||||
|
|
||||||
toString()
|
toString()
|
||||||
{
|
{
|
||||||
return 'ereject ' + this._reason + ';';
|
return 'ereject ' + this._reason + ';';
|
||||||
|
|
@ -50,9 +51,10 @@ class Reject extends Grammar.Command
|
||||||
{
|
{
|
||||||
super('reject');
|
super('reject');
|
||||||
this._reason = new Grammar.QuotedString;
|
this._reason = new Grammar.QuotedString;
|
||||||
// this.require = 'reject';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get require() { return 'reject'; }
|
||||||
|
|
||||||
toString()
|
toString()
|
||||||
{
|
{
|
||||||
return 'reject ' + this._reason + ';';
|
return 'reject ' + this._reason + ';';
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ Sieve.parseScript = script => {
|
||||||
|
|
||||||
levels = [],
|
levels = [],
|
||||||
command = null,
|
command = null,
|
||||||
|
requires = [],
|
||||||
args = [];
|
args = [];
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -128,10 +129,19 @@ Sieve.parseScript = script => {
|
||||||
}
|
}
|
||||||
levels.push(new_command);
|
levels.push(new_command);
|
||||||
command = new_command;
|
command = new_command;
|
||||||
|
if (command.require) {
|
||||||
|
(Array.isArray(command.require) ? command.require : [command.require])
|
||||||
|
.forEach(string => requires.push(string));
|
||||||
|
}
|
||||||
break; }
|
break; }
|
||||||
|
|
||||||
// Arguments
|
// Arguments
|
||||||
case T_TAG:
|
case T_TAG:
|
||||||
|
/*
|
||||||
|
if (':value' === value || ':count' === value) {
|
||||||
|
requires.push('relational');
|
||||||
|
}
|
||||||
|
*/
|
||||||
command
|
command
|
||||||
? args.push(value.toLowerCase())
|
? args.push(value.toLowerCase())
|
||||||
: error('Tag must be command argument');
|
: error('Tag must be command argument');
|
||||||
|
|
@ -179,6 +189,9 @@ Sieve.parseScript = script => {
|
||||||
case T_SEMICOLON:
|
case T_SEMICOLON:
|
||||||
command || error('Semicolon not at end of command');
|
command || error('Semicolon not at end of command');
|
||||||
pushArgs();
|
pushArgs();
|
||||||
|
if (command instanceof Commands.require) {
|
||||||
|
command.capabilities.forEach(string => requires.push(string.value));
|
||||||
|
}
|
||||||
levels.pop();
|
levels.pop();
|
||||||
command = levels.last();
|
command = levels.last();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,8 @@ class Envelope extends Test
|
||||||
this.key_list = new StringList;
|
this.key_list = new StringList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get require() { return 'envelope'; }
|
||||||
|
|
||||||
toString()
|
toString()
|
||||||
{
|
{
|
||||||
return 'envelope'
|
return 'envelope'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue