Skip to content

Commit

Permalink
fixup! feat: mail filters
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kesselberg <[email protected]>
  • Loading branch information
kesselb committed Sep 13, 2024
1 parent b7e29f1 commit f306877
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/Service/MailFilter/FilterBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ private function sanitizeDefinition(array $filters): array {
unset($action['id']);
return $action;
}, $filter['actions']);
$filter['priority'] = (int)$filter['priority'];
return $filter;
}, $filters);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/builder2.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require ["fileinto"];
### Nextcloud Mail: Filters ### DON'T EDIT ###
# Hello, this is a test
### Nextcloud Mail: Filters ### DON'T EDIT ###
# DATA: [{"name":"Test 2","enable":true,"operator":"anyof","tests":[{"operator":"contains","values":["Project-A","Project-B"],"field":"subject"},{"operator":"is","values":["[email protected]"],"field":"from"}],"actions":[{"type":"fileinto","flag":"","mailbox":"Test Data"}],"priority":"20"}]
# DATA: [{"name":"Test 2","enable":true,"operator":"anyof","tests":[{"operator":"contains","values":["Project-A","Project-B"],"field":"subject"},{"operator":"is","values":["[email protected]"],"field":"from"}],"actions":[{"type":"fileinto","flag":"","mailbox":"Test Data"}],"priority":20}]
# Filter: Test 2
if anyof (header :contains "Subject" ["Project-A", "Project-B"], address :is :all "From" ["[email protected]"]) {
fileinto "Test Data";
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/builder3.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require ["fileinto", "imap4flags"];
### Nextcloud Mail: Filters ### DON'T EDIT ###
# Hello, this is a test
### Nextcloud Mail: Filters ### DON'T EDIT ###
# DATA: [{"name":"Test 3.1","enable":true,"operator":"anyof","tests":[{"operator":"contains","values":["Project-A","Project-B"],"field":"subject"},{"operator":"is","values":["[email protected]"],"field":"from"}],"actions":[{"type":"fileinto","flag":"","mailbox":"Test Data"},{"type":"stop"}],"priority":"20"},{"name":"Test 3.2","enable":true,"operator":"allof","tests":[{"operator":"contains","values":["@example.org"],"field":"to"}],"actions":[{"type":"addflag","flag":"Test A"}],"priority":30}]
# DATA: [{"name":"Test 3.1","enable":true,"operator":"anyof","tests":[{"operator":"contains","values":["Project-A","Project-B"],"field":"subject"},{"operator":"is","values":["[email protected]"],"field":"from"}],"actions":[{"type":"fileinto","flag":"","mailbox":"Test Data"},{"type":"stop"}],"priority":20},{"name":"Test 3.2","enable":true,"operator":"allof","tests":[{"operator":"contains","values":["@example.org"],"field":"to"}],"actions":[{"type":"addflag","flag":"Test A"}],"priority":30}]
# Filter: Test 3.1
if anyof (header :contains "Subject" ["Project-A", "Project-B"], address :is :all "From" ["[email protected]"]) {
fileinto "Test Data";
Expand Down
11 changes: 11 additions & 0 deletions tests/data/mail-filter/parser1.sieve
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Nextcloud Mail: Filters ### DON'T EDIT ###
require ["imap4flags"];
### Nextcloud Mail: Filters ### DON'T EDIT ###
# Hello, this is a test
### Nextcloud Mail: Filters ### DON'T EDIT ###
# DATA: [{"name":"Test 1","enable":true,"operator":"allof","tests":[{"operator":"is","values":["[email protected]","[email protected]"],"field":"from"}],"actions":[{"type":"addflag","flag":"Alice and Bob"}],"priority":10}]
# Filter: Test 1
if address :is :all "From" ["[email protected]", "[email protected]"] {
addflag "$alice_and_bob";
}
### Nextcloud Mail: Filters ### DON'T EDIT ###

0 comments on commit f306877

Please sign in to comment.