From 44c2e68f3c1ca2b8f062c265a40f4f6458f06127 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Fri, 13 Sep 2024 13:15:51 +0200 Subject: [PATCH] fixup! feat: mail filters Signed-off-by: Daniel Kesselberg --- lib/Service/MailFilter/FilterBuilder.php | 1 + tests/data/mail-filter/test3.sieve | 2 +- tests/data/mail-filter/test4.json | 15 +++++++++++++++ tests/data/mail-filter/test4.sieve | 7 +++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/data/mail-filter/test4.json create mode 100644 tests/data/mail-filter/test4.sieve diff --git a/lib/Service/MailFilter/FilterBuilder.php b/lib/Service/MailFilter/FilterBuilder.php index 5b8673dc8d..9a63aeabe3 100644 --- a/lib/Service/MailFilter/FilterBuilder.php +++ b/lib/Service/MailFilter/FilterBuilder.php @@ -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; } diff --git a/tests/data/mail-filter/test3.sieve b/tests/data/mail-filter/test3.sieve index efc61c31f9..292e06f42b 100644 --- a/tests/data/mail-filter/test3.sieve +++ b/tests/data/mail-filter/test3.sieve @@ -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":["john@example.org"],"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":["john@example.org"],"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" ["john@example.org"]) { fileinto "Test Data"; diff --git a/tests/data/mail-filter/test4.json b/tests/data/mail-filter/test4.json new file mode 100644 index 0000000000..c02d4c469d --- /dev/null +++ b/tests/data/mail-filter/test4.json @@ -0,0 +1,15 @@ +[ + { + "actions": [ + { + "flag": "Flag 123", + "type": "addflag" + } + ], + "enable": true, + "name": "Test 4", + "operator": "allof", + "priority": 60, + "tests": [] + } +] diff --git a/tests/data/mail-filter/test4.sieve b/tests/data/mail-filter/test4.sieve new file mode 100644 index 0000000000..28e18b4a08 --- /dev/null +++ b/tests/data/mail-filter/test4.sieve @@ -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 ###