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 4a69d12 commit 44c2e68
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/Service/MailFilter/FilterBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function buildSieveScript(array $filters, string $untouchedScript): strin

if (count($tests) === 0) {
// skip filter without tests
$commands[] = '# No valid tests found';
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/test3.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require ["fileinto", "imap4flags"];
# 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 B","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
15 changes: 15 additions & 0 deletions tests/data/mail-filter/test4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
"actions": [
{
"flag": "Flag 123",
"type": "addflag"
}
],
"enable": true,
"name": "Test 4",
"operator": "allof",
"priority": 60,
"tests": []
}
]
7 changes: 7 additions & 0 deletions tests/data/mail-filter/test4.sieve
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Hello, this is a test

### Nextcloud Mail: Filters ### DON'T EDIT ###
# DATA: [{"actions":[{"flag":"Flag 123","type":"addflag"}],"enable":true,"name":"Test 4","operator":"allof","priority":60,"tests":[]}]
# Filter: Test 4
# No valid tests found
### Nextcloud Mail: Filters ### DON'T EDIT ###

0 comments on commit 44c2e68

Please sign in to comment.