2022-03-09 19:33:31 +08:00
|
|
|
/**
|
2022-03-17 16:03:02 +08:00
|
|
|
* https://datatracker.ietf.org/doc/html/rfc5228#section-4
|
|
|
|
* Action commands do not take tests or blocks as arguments.
|
2022-03-09 19:33:31 +08:00
|
|
|
*/
|
|
|
|
|
2022-03-14 21:06:28 +08:00
|
|
|
import { capa } from 'Sieve/Utils';
|
|
|
|
|
2022-03-09 19:33:31 +08:00
|
|
|
import {
|
2022-03-17 16:03:02 +08:00
|
|
|
ActionCommand,
|
2022-03-09 19:33:31 +08:00
|
|
|
GrammarString,
|
|
|
|
GrammarQuotedString
|
|
|
|
} from 'Sieve/Grammar';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* https://tools.ietf.org/html/rfc5228#section-4.1
|
|
|
|
*/
|
2022-03-17 16:03:02 +08:00
|
|
|
export class FileIntoCommand extends ActionCommand
|
2022-03-09 19:33:31 +08:00
|
|
|
{
|
|
|
|
constructor()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
// QuotedString / MultiLine
|
|
|
|
this._mailbox = new GrammarQuotedString();
|
|
|
|
}
|
|
|
|
|
|
|
|
get require() { return 'fileinto'; }
|
|
|
|
|
|
|
|
toString()
|
|
|
|
{
|
2022-03-16 21:21:23 +08:00
|
|
|
return 'fileinto'
|
2022-03-14 21:06:28 +08:00
|
|
|
// https://datatracker.ietf.org/doc/html/rfc3894
|
2022-03-16 21:21:23 +08:00
|
|
|
+ ((this.copy && capa.includes('copy')) ? ' :copy' : '')
|
2022-03-14 21:06:28 +08:00
|
|
|
// https://datatracker.ietf.org/doc/html/rfc5490#section-3.2
|
2022-03-16 21:21:23 +08:00
|
|
|
+ ((this.create && capa.includes('mailbox')) ? ' :create' : '')
|
|
|
|
+ ' ' + this._mailbox
|
2022-03-14 21:06:28 +08:00
|
|
|
+ ';';
|
2022-03-09 19:33:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
get mailbox()
|
|
|
|
{
|
|
|
|
return this._mailbox.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
set mailbox(value)
|
|
|
|
{
|
|
|
|
this._mailbox.value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
pushArguments(args)
|
|
|
|
{
|
|
|
|
if (args[0] instanceof GrammarString) {
|
|
|
|
this._mailbox = args[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* https://tools.ietf.org/html/rfc5228#section-4.2
|
|
|
|
*/
|
2022-03-17 16:03:02 +08:00
|
|
|
export class RedirectCommand extends ActionCommand
|
2022-03-09 19:33:31 +08:00
|
|
|
{
|
|
|
|
constructor()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
// QuotedString / MultiLine
|
|
|
|
this._address = new GrammarQuotedString();
|
|
|
|
}
|
|
|
|
|
|
|
|
toString()
|
|
|
|
{
|
2022-03-16 21:21:23 +08:00
|
|
|
|
|
|
|
return 'redirect'
|
|
|
|
// https://datatracker.ietf.org/doc/html/rfc6134#section-2.3
|
|
|
|
// + ((this.list && capa.includes('extlists')) ? ' :list ' + this.list : '')
|
2022-03-14 21:06:28 +08:00
|
|
|
// https://datatracker.ietf.org/doc/html/rfc3894
|
2022-03-16 21:21:23 +08:00
|
|
|
+ ((this.copy && capa.includes('copy')) ? ' :copy' : '')
|
|
|
|
+ ' ' + this._address
|
2022-03-14 21:06:28 +08:00
|
|
|
+ ';';
|
2022-03-09 19:33:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
get address()
|
|
|
|
{
|
|
|
|
return this._address.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
set address(value)
|
|
|
|
{
|
|
|
|
this._address.value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
pushArguments(args)
|
|
|
|
{
|
|
|
|
if (args[0] instanceof GrammarString) {
|
|
|
|
this._address = args[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* https://tools.ietf.org/html/rfc5228#section-4.3
|
|
|
|
*/
|
2022-03-17 16:03:02 +08:00
|
|
|
export class KeepCommand extends ActionCommand
|
2022-03-09 19:33:31 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* https://tools.ietf.org/html/rfc5228#section-4.4
|
|
|
|
*/
|
2022-03-17 16:03:02 +08:00
|
|
|
export class DiscardCommand extends ActionCommand
|
2022-03-09 19:33:31 +08:00
|
|
|
{
|
|
|
|
}
|