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 Oct 1, 2024
1 parent 3444c7f commit debfa2c
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/Service/MailFilter/FilterBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function buildSieveScript(array $filters, string $untouchedScript): strin
continue;
}

$commands[] = '# Filter: ' . $filter['name'];
$commands[] = '# ' . $filter['name'];

$tests = [];
foreach ($filter['tests'] as $test) {
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/builder1.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require ["imap4flags"];
# Hello, this is a test
### Nextcloud Mail: Filters ### DON'T EDIT ###
# FILTER: [{"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
# Test 1
if address :is :all "From" ["[email protected]", "[email protected]"] {
addflag "$alice_and_bob";
}
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 @@ -4,7 +4,7 @@ require ["fileinto"];
# Hello, this is a test
### Nextcloud Mail: Filters ### DON'T EDIT ###
# FILTER: [{"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","mailbox":"Test Data"}],"priority":20}]
# Filter: Test 2
# Test 2
if anyof (header :contains "Subject" ["Project-A", "Project-B"], address :is :all "From" ["[email protected]"]) {
fileinto "Test Data";
}
Expand Down
4 changes: 2 additions & 2 deletions tests/data/mail-filter/builder3.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ require ["fileinto", "imap4flags"];
# Hello, this is a test
### Nextcloud Mail: Filters ### DON'T EDIT ###
# FILTER: [{"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","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
# Test 3.1
if anyof (header :contains "Subject" ["Project-A", "Project-B"], address :is :all "From" ["[email protected]"]) {
fileinto "Test Data";
stop;
}
# Filter: Test 3.2
# Test 3.2
if address :contains :all "To" ["@example.org"] {
addflag "$test_a";
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/builder4.sieve
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hello, this is a test
### Nextcloud Mail: Filters ### DON'T EDIT ###
# FILTER: [{"actions":[{"flag":"Flag 123","type":"addflag"}],"enable":true,"name":"Test 4","operator":"allof","priority":60,"tests":[]}]
# Filter: Test 4
# Test 4
# No valid tests found
### Nextcloud Mail: Filters ### DON'T EDIT ###
2 changes: 1 addition & 1 deletion tests/data/mail-filter/builder5.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require ["imap4flags"];
# Hello, this is a test
### Nextcloud Mail: Filters ### DON'T EDIT ###
# FILTER: [{"actions":[{"flag":"Report","type":"addflag"},{"flag":"To read","type":"addflag"}],"enable":true,"name":"Test 5","operator":"allof","priority":10,"tests":[{"field":"subject","operator":"matches","values":["work*report"]}]}]
# Filter: Test 5
# Test 5
if header :matches "Subject" ["work*report"] {
addflag "$report";
addflag "$to_read";
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/builder6.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require ["fileinto", "imap4flags"];
# Hello, this is a test
### Nextcloud Mail: Filters ### DON'T EDIT ###
# FILTER: [{"actions":[{"mailbox":"Test Data","type":"fileinto"},{"flag":"Projects\\Reporting","type":"addflag"}],"enable":true,"name":"Test 6","operator":"anyof","priority":10,"tests":[{"field":"subject","operator":"is","values":["\"Project-A\"","Project\\A"]},{"field":"subject","operator":"is","values":["\"Project-B\"","Project\\B"]}]}]
# Filter: Test 6
# Test 6
if anyof (header :is "Subject" ["\"Project-A\"", "Project\\A"], header :is "Subject" ["\"Project-B\"", "Project\\B"]) {
fileinto "Test Data";
addflag "$projects\\reporting";
Expand Down
4 changes: 2 additions & 2 deletions tests/data/mail-filter/parser1.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ 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
# FILTER: [{"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}]
# Test 1
if address :is :all "From" ["[email protected]", "[email protected]"] {
addflag "$alice_and_bob";
}
Expand Down
4 changes: 2 additions & 2 deletions tests/data/mail-filter/parser2.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ 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}]
# Filter: Test 2
# FILTER: [{"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}]
# Test 2
if anyof (header :contains "Subject" ["Project-A", "Project-B"], address :is :all "From" ["[email protected]"]) {
fileinto "Test Data";
}
Expand Down

0 comments on commit debfa2c

Please sign in to comment.