mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-24 14:57:26 +08:00
Solve some comparators
This commit is contained in:
parent
43c669e629
commit
55178016a0
3 changed files with 58 additions and 14 deletions
|
@ -35,10 +35,14 @@ class Body extends Grammar.Test
|
|||
this.match_type = arg;
|
||||
} else if (':raw' === arg || ':text' === arg) {
|
||||
this.body_transform = arg;
|
||||
} else if (':content' === arg) {
|
||||
// string-list
|
||||
} else if (arg instanceof Grammar.StringList || arg instanceof Grammar.StringType) {
|
||||
this[args[i+1] ? 'content_list' : 'key_list'] = arg;
|
||||
if (':comparator' === args[i-1]) {
|
||||
this.comparator = arg;
|
||||
} else if (':content' === args[i-1]) {
|
||||
this.body_transform = ':content ' + arg;
|
||||
} else {
|
||||
this[args[i+1] ? 'content_list' : 'key_list'] = arg;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -99,7 +99,11 @@ class HasFlag extends Grammar.Test
|
|||
if (':is' === arg || ':contains' === arg || ':matches' === arg) {
|
||||
this.match_type = arg;
|
||||
} else if (arg instanceof Grammar.StringList || arg instanceof Grammar.StringType) {
|
||||
this[args[i+1] ? 'variable_list' : 'list_of_flags'] = arg;
|
||||
if (':comparator' === args[i-1]) {
|
||||
this.comparator = arg;
|
||||
} else {
|
||||
this[args[i+1] ? 'variable_list' : 'list_of_flags'] = arg;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -33,9 +33,22 @@ class Address extends Test
|
|||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(/*args*/)
|
||||
pushArguments(args)
|
||||
{
|
||||
throw 'TODO';
|
||||
args.forEach((arg, i) => {
|
||||
if (':is' === arg || ':contains' === arg || ':matches' === arg) {
|
||||
this.match_type = arg;
|
||||
} else if (':localpart' === arg || ':domain' === arg || ':all' === arg) {
|
||||
this.address_part = arg;
|
||||
} else if (arg instanceof StringList || arg instanceof Grammar.StringType) {
|
||||
if (':comparator' === args[i-1]) {
|
||||
this.comparator = arg;
|
||||
} else {
|
||||
this[args[i+1] ? 'header_list' : 'key_list'] = arg;
|
||||
// (args[i+1] ? this.header_list : this.key_list) = arg;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,9 +113,22 @@ class Envelope extends Test
|
|||
+ ' ' + this.key_list;
|
||||
}
|
||||
|
||||
pushArguments(/*args*/)
|
||||
pushArguments(args)
|
||||
{
|
||||
throw 'TODO';
|
||||
args.forEach((arg, i) => {
|
||||
if (':is' === arg || ':contains' === arg || ':matches' === arg) {
|
||||
this.match_type = arg;
|
||||
} else if (':localpart' === arg || ':domain' === arg || ':all' === arg) {
|
||||
this.address_part = arg;
|
||||
} else if (arg instanceof StringList || arg instanceof Grammar.StringType) {
|
||||
if (':comparator' === args[i-1]) {
|
||||
this.comparator = arg;
|
||||
} else {
|
||||
this[args[i+1] ? 'envelope_part' : 'key_list'] = arg;
|
||||
// (args[i+1] ? this.envelope_part : this.key_list) = arg;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,9 +148,13 @@ class Exists extends Test
|
|||
return 'exists ' + this.header_names;
|
||||
}
|
||||
|
||||
pushArguments(/*args*/)
|
||||
pushArguments(args)
|
||||
{
|
||||
throw 'TODO';
|
||||
if (args[0] instanceof StringList) {
|
||||
this.header_names = args;
|
||||
} else if (args[0] instanceof Grammar.StringType) {
|
||||
this.header_names.push(args[0].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,9 +198,15 @@ class Header extends Test
|
|||
args.forEach((arg, i) => {
|
||||
if (':is' === arg || ':contains' === arg || ':matches' === arg) {
|
||||
this.match_type = arg;
|
||||
} else if (':localpart' === arg || ':domain' === arg || ':all' === arg) {
|
||||
this.address_part = arg;
|
||||
} else if (arg instanceof StringList || arg instanceof Grammar.StringType) {
|
||||
this[args[i+1] ? 'header_names' : 'key_list'] = arg;
|
||||
// (args[i+1] ? this.header_names : this.key_list) = arg;
|
||||
if (':comparator' === args[i-1]) {
|
||||
this.comparator = arg;
|
||||
} else {
|
||||
this[args[i+1] ? 'header_names' : 'key_list'] = arg;
|
||||
// (args[i+1] ? this.header_names : this.key_list) = arg;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -192,9 +228,9 @@ class Not extends Test
|
|||
return 'not ' + this.test;
|
||||
}
|
||||
|
||||
pushArguments(/*args*/)
|
||||
pushArguments()
|
||||
{
|
||||
throw 'TODO';
|
||||
throw 'No arguments';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue