Skip to content

Commit

Permalink
Merge pull request #18 from josaphatim/finalize-rfcs-for-actions
Browse files Browse the repository at this point in the history
Added support for multiple RFCs for actions that have it
  • Loading branch information
kroky authored May 22, 2024
2 parents 2731ca3 + 9a5797d commit 55d2f26
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/Filters/Actions/BaseFlagFilterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ abstract class BaseFlagFilterAction extends BaseSieveAction

public function getRequiredParams()
{
return ['list-of-flags'];
return ['flags'];
}

protected function getParamTypes() {
return [
'variablename' => 'string',
'list-of-flags' => 'string-list'
'flags' => 'string-list'
];
}

Expand All @@ -26,7 +26,7 @@ public function parse() {
if (!empty($this->params['variablename'])) {
$script .= "\"{$this->params['variablename']}\"";
}
$script .= " [" . implode(', ', array_map(function($flag) { return "\"$flag\""; }, $this->params['list-of-flags'])) . "];\n";
$script .= " [" . implode(', ', array_map(function($flag) { return "\"$flag\""; }, $this->params['flags'])) . "];\n";

return $script;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Filters/Actions/EncloseFilterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ protected function getParamTypes() {
* @return string
*/
public function parse() {
return "enclose :subject \"{$this->subject}\" :headers [\"" . implode('", "', $this->headers) . "\"] \"{$this->content}\";\n";
return "enclose :subject \"{$this->params['subject']}\" :headers [\"" . implode('", "', $this->params['headers']) . "\"] \"{$this->params['content']}\";\n";
}
}
2 changes: 1 addition & 1 deletion src/Filters/Actions/ExtractTextFilterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function parse() {
if (!empty($this->params['first'])) {
$script .= " :first {$this->params['first']}";
}
$script .= " \"{$this->params['varName']}\";\n";
$script .= " \"{$this->params['varname']}\";\n";
return $script;
}
}
33 changes: 31 additions & 2 deletions src/Filters/Actions/FileIntoFilterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,42 @@ protected function getRequiredParams()
}

protected function getParamTypes() {
return ['mailbox' => 'string'];
return [
'mailbox' => 'string',
'flags' => 'string-list',
'copy' => 'bool',
'mailboxid' => 'string',
'create' => 'bool',
'specialuse' => 'string',
];
}

/**
* @return string
*/
public function parse() {
return "fileinto \"{$this->params['mailbox']}\";\n";
$script = "fileinto";
if (!empty($this->params['special-use-attr'])) {
$this->require[] = 'special-use';
$script .= " :specialuse \"{$this->params['specialuse']}\"";
}
if (!empty($this->params['create'])) {
$this->require[] = 'mailbox';
$script .= " :create";
}
if (!empty($this->params['mailboxid'])) {
$this->require[] = 'mailboxid';
$script .= " :mailboxid \"{$this->params['mailboxid']}\"";
}
if (!empty($this->params['copy'])) {
$this->require[] = 'copy';
$script .= " :copy";
}
if (!empty($this->params['flags'])) {
$this->require[] = 'imap4flags';
$script .= " :flags \"" . implode('", "', $this->params['flags']) . "\"";
}
$script .= " \"{$this->params['mailbox']}\";\n";
return $script;
}
}
21 changes: 14 additions & 7 deletions src/Filters/Actions/KeepFilterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

class KeepFilterAction extends BaseSieveAction
{
/**
* @return string
*/
public function parse() {
return "keep;\n";
}
public $require = [];

public function getRequiredParams()
{
Expand All @@ -18,6 +13,18 @@ public function getRequiredParams()

public function getParamTypes()
{
return [];
return ['flags' => 'string-list'];
}

/**
* @return string
*/
public function parse() {
$flags = '';
if (!empty($this->params['flags'])) {
$this->require[] = 'imap4flags';
$flags = " :flags \"" . implode('", "', $this->params['flags']) . "\"";
}
return "keep{$flags};\n";
}
}
5 changes: 5 additions & 0 deletions src/Filters/Actions/NotifyFilterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected function getParamTypes() {
'importance' => 'int',
'options' => 'string-list',
'message' => 'string',
'fcc' => 'string',
'method' => 'string',
];
}
Expand All @@ -38,6 +39,10 @@ public function parse() {
if (!empty($this->params['options'])) {
$script .= " :options [\"" . implode('", "', $this->params['options']) . "\"]";
}
if (!empty($this->params['fcc'])) {
$this->require[] = 'fcc';
$script .= " :fcc \"{$this->params['fcc']}\"";
}
if (!empty($this->params['message'])) {
$script .= " :message \"{$this->params['message']}\"";
}
Expand Down
26 changes: 24 additions & 2 deletions src/Filters/Actions/RedirectFilterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,41 @@

class RedirectFilterAction extends BaseSieveAction
{
public $require = [];

protected function getRequiredParams()
{
return ['address'];
}

protected function getParamTypes() {
return ['address' => 'string'];
return [
'address' => 'string',
'copy' => 'bool',
'notify' => 'string',
'ret' => 'string',
];
}

/**
* @return string
*/
public function parse() {
return "redirect \"{$this->params['address']}\";\n";
$script = "redirect";
if (!empty($this->params['copy'])) {
$this->require[] = 'copy';
$script .= " :copy";
}
if (isset($this->params['notify']) || isset($this->params['notify'])) {
$this->require[] = 'redirect-dsn';
}
if (!empty($this->params['notify'])) {
$script .= " :notify \"{$this->params['notify']}\"";
}
if (!empty($this->params['ret'])) {
$script .= " :ret \"{$this->params['ret']}\"";
}
$script .= " \"{$this->params['address']}\";\n";
return $script;
}
}

0 comments on commit 55d2f26

Please sign in to comment.