Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/Service/OutOfOffice/OutOfOfficeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ public function buildSieveScript(
$vacationCondition = "currentdate :value \"ge\" \"iso8601\" \"$formattedStart\"";
}

$automaticMailCondition = 'anyof(exists "List-Id", exists "List-Unsubscribe")';
$skipConditions = [
'exists "List-Id"',
'exists "List-Unsubscribe"',
'address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]',
];

$automaticMailCondition = 'anyof(' . join(', ', $skipConditions) . ')';
Comment on lines +123 to +129

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Update the enabled-responder fixture before merging.

The new condition changes the complete Sieve output. tests/Unit/Service/OutOfOffice/OutOfOfficeParserTest.php still compares that output with tests/data/sieve-vacation-on.sieve, which does not contain the new address condition. Update the fixture and add focused coverage for both noreply@* and no-reply@* in the From and Sender headers.


$escapedSubject = SieveUtils::escapeString($state->getSubject());
$vacation = [
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/parser3.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if allof(
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2022-09-02T00:00:00+01:00","end":"2022-09-08T23:59:00+01:00","subject":"On vacation","message":"I'm on vacation."}
if allof(currentdate :value "ge" "iso8601" "2022-09-01T23:00:00Z", currentdate :value "le" "iso8601" "2022-09-08T22:59:00Z") {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "On vacation" :addresses ["Test Test <test@test.org>", "Test Alias <alias@test.org>"] "I'm on vacation.";
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/parser3_untouched.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if allof(
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2022-09-02T00:00:00+01:00","end":"2022-09-08T23:59:00+01:00","subject":"On vacation","message":"I'm on vacation."}
if allof(currentdate :value "ge" "iso8601" "2022-09-01T23:00:00Z", currentdate :value "le" "iso8601" "2022-09-08T22:59:00Z") {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "On vacation" :addresses ["Test Test <test@test.org>", "Test Alias <alias@test.org>"] "I'm on vacation.";
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/parser4.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if address :is :all "From" ["marketing@mail.internal"] {
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2024-10-08T22:00:00+00:00","subject":"Thanks for your message!","message":"I'm not here, please try again later.\u00a0"}
if currentdate :value "ge" "iso8601" "2024-10-08T22:00:00Z" {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "Thanks for your message!" :addresses ["alice@mail.internal"] "I'm not here, please try again later. ";
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/parser4_untouched.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if allof(
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2024-10-08T22:00:00+00:00","subject":"Thanks for your message!","message":"I'm not here, please try again later.\u00a0"}
if currentdate :value "ge" "iso8601" "2024-10-08T22:00:00Z" {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "Thanks for your message!" :addresses ["alice@mail.internal"] "I'm not here, please try again later. ";
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/service1.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if allof(
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2024-10-08T22:00:00+00:00","subject":"Thanks for your message!","message":"I'm not here, please try again later.\u00a0"}
if currentdate :value "ge" "iso8601" "2024-10-08T22:00:00Z" {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "Thanks for your message!" :addresses ["alice@mail.internal"] "I'm not here, please try again later. ";
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/service1_new.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if address :is :all "From" ["marketing@mail.internal"] {
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2024-10-08T22:00:00+00:00","subject":"Thanks for your message!","message":"I'm not here, please try again later.\u00a0"}
if currentdate :value "ge" "iso8601" "2024-10-08T22:00:00Z" {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "Thanks for your message!" :addresses ["alice@mail.internal"] "I'm not here, please try again later. ";
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/service2.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if header :contains "Subject" ["World"] {
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2024-10-08T22:00:00+00:00","subject":"Thanks for your message!","message":"I'm not here, please try again later.\u00a0"}
if currentdate :value "ge" "iso8601" "2024-10-08T22:00:00Z" {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "Thanks for your message!" :addresses ["alice@mail.internal"] "I'm not here, please try again later. ";
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mail-filter/service2_new.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if header :contains "Subject" ["Hello"] {
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2024-10-08T22:00:00+00:00","subject":"Thanks for your message!","message":"I'm not here, please try again later.\u00a0"}
if currentdate :value "ge" "iso8601" "2024-10-08T22:00:00Z" {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "Thanks for your message!" :addresses ["alice@mail.internal"] "I'm not here, please try again later. ";
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/sieve-vacation-on-no-end-date.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if address "From" "marketing@company.org" {
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2022-09-02T00:00:00+01:00","subject":"On vacation","message":"I'm on vacation."}
if currentdate :value "ge" "iso8601" "2022-09-01T23:00:00Z" {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "On vacation" :addresses ["Test Test <test@test.org>", "Test Alias <alias@test.org>"] "I'm on vacation.";
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/sieve-vacation-on-no-tz.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if address "From" "marketing@company.org" {
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2022-09-02","end":"2022-09-08","subject":"On vacation","message":"I'm on vacation."}
if allof(currentdate :value "ge" "iso8601" "2022-09-01", currentdate :value "le" "iso8601" "2022-09-08") {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "On vacation" :addresses ["Test Test <test@test.org>", "Test Alias <alias@test.org>"] "I'm on vacation.";
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/sieve-vacation-on-special-chars-message.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if address "From" "marketing@company.org" {
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2022-09-02T00:00:00+01:00","subject":"On vacation","message":"I'm on vacation.\r\n\"Hello, World!\"\r\n\\ escaped backslash"}
if currentdate :value "ge" "iso8601" "2022-09-01T23:00:00Z" {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "On vacation" :addresses ["Test Test <test@test.org>", "Test Alias <alias@test.org>"] "I'm on vacation.
\"Hello, World!\"
\\ escaped backslash";
Expand Down
2 changes: 1 addition & 1 deletion tests/data/sieve-vacation-on-special-chars-subject.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if address "From" "marketing@company.org" {
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2022-09-02T00:00:00+01:00","subject":"On vacation, \"Hello, World!\", \\ escaped backslash","message":"I'm on vacation."}
if currentdate :value "ge" "iso8601" "2022-09-01T23:00:00Z" {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "On vacation, \"Hello, World!\", \\ escaped backslash" :addresses ["Test Test <test@test.org>", "Test Alias <alias@test.org>"] "I'm on vacation.";
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/sieve-vacation-on-subject-placeholder.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if header :matches "subject" "*" {
set "subject" "${1}";
}
if allof(currentdate :value "ge" "iso8601" "2022-09-01T23:00:00Z", currentdate :value "le" "iso8601" "2022-09-08T22:59:00Z") {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "Re: ${subject}" :addresses ["Test Test <test@test.org>", "Test Alias <alias@test.org>"] "I'm on vacation.";
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/sieve-vacation-on.sieve
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if address "From" "marketing@company.org" {
### Nextcloud Mail: Vacation Responder ### DON'T EDIT ###
# DATA: {"version":1,"enabled":true,"start":"2022-09-02T00:00:00+01:00","end":"2022-09-08T23:59:00+01:00","subject":"On vacation","message":"I'm on vacation."}
if allof(currentdate :value "ge" "iso8601" "2022-09-01T23:00:00Z", currentdate :value "le" "iso8601" "2022-09-08T22:59:00Z") {
if not anyof(exists "List-Id", exists "List-Unsubscribe") {
if not anyof(exists "List-Id", exists "List-Unsubscribe", address :all :matches ["From", "Sender"] ["noreply@*", "no-reply@*"]) {
vacation :days 4 :subject "On vacation" :addresses ["Test Test <test@test.org>", "Test Alias <alias@test.org>"] "I'm on vacation.";
}
}
Expand Down
Loading