diff --git a/lib/Service/OutOfOffice/OutOfOfficeParser.php b/lib/Service/OutOfOffice/OutOfOfficeParser.php index 6f41ea9e9a..939948265d 100644 --- a/lib/Service/OutOfOffice/OutOfOfficeParser.php +++ b/lib/Service/OutOfOffice/OutOfOfficeParser.php @@ -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) . ')'; $escapedSubject = SieveUtils::escapeString($state->getSubject()); $vacation = [ diff --git a/tests/data/mail-filter/parser3.sieve b/tests/data/mail-filter/parser3.sieve index 72436eaf43..4896bcd982 100644 --- a/tests/data/mail-filter/parser3.sieve +++ b/tests/data/mail-filter/parser3.sieve @@ -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 Alias "] "I'm on vacation."; } } diff --git a/tests/data/mail-filter/parser3_untouched.sieve b/tests/data/mail-filter/parser3_untouched.sieve index 72436eaf43..4896bcd982 100644 --- a/tests/data/mail-filter/parser3_untouched.sieve +++ b/tests/data/mail-filter/parser3_untouched.sieve @@ -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 Alias "] "I'm on vacation."; } } diff --git a/tests/data/mail-filter/parser4.sieve b/tests/data/mail-filter/parser4.sieve index 27089ec26b..c74b6aaa70 100644 --- a/tests/data/mail-filter/parser4.sieve +++ b/tests/data/mail-filter/parser4.sieve @@ -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. "; } } diff --git a/tests/data/mail-filter/parser4_untouched.sieve b/tests/data/mail-filter/parser4_untouched.sieve index 1e7ad1e131..cb96705acc 100644 --- a/tests/data/mail-filter/parser4_untouched.sieve +++ b/tests/data/mail-filter/parser4_untouched.sieve @@ -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. "; } } diff --git a/tests/data/mail-filter/service1.sieve b/tests/data/mail-filter/service1.sieve index 1e7ad1e131..cb96705acc 100644 --- a/tests/data/mail-filter/service1.sieve +++ b/tests/data/mail-filter/service1.sieve @@ -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. "; } } diff --git a/tests/data/mail-filter/service1_new.sieve b/tests/data/mail-filter/service1_new.sieve index 27089ec26b..c74b6aaa70 100644 --- a/tests/data/mail-filter/service1_new.sieve +++ b/tests/data/mail-filter/service1_new.sieve @@ -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. "; } } diff --git a/tests/data/mail-filter/service2.sieve b/tests/data/mail-filter/service2.sieve index cd2153b7ee..69cbde9868 100644 --- a/tests/data/mail-filter/service2.sieve +++ b/tests/data/mail-filter/service2.sieve @@ -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. "; } } diff --git a/tests/data/mail-filter/service2_new.sieve b/tests/data/mail-filter/service2_new.sieve index 348af990f7..c73642dacc 100644 --- a/tests/data/mail-filter/service2_new.sieve +++ b/tests/data/mail-filter/service2_new.sieve @@ -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. "; } } diff --git a/tests/data/sieve-vacation-on-no-end-date.sieve b/tests/data/sieve-vacation-on-no-end-date.sieve index ceb93e983f..3f7adcc242 100644 --- a/tests/data/sieve-vacation-on-no-end-date.sieve +++ b/tests/data/sieve-vacation-on-no-end-date.sieve @@ -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 Alias "] "I'm on vacation."; } } diff --git a/tests/data/sieve-vacation-on-no-tz.sieve b/tests/data/sieve-vacation-on-no-tz.sieve index a35b43cf8c..e11eca0696 100644 --- a/tests/data/sieve-vacation-on-no-tz.sieve +++ b/tests/data/sieve-vacation-on-no-tz.sieve @@ -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 Alias "] "I'm on vacation."; } } diff --git a/tests/data/sieve-vacation-on-special-chars-message.sieve b/tests/data/sieve-vacation-on-special-chars-message.sieve index 455b6d1264..fcfbe39b31 100644 --- a/tests/data/sieve-vacation-on-special-chars-message.sieve +++ b/tests/data/sieve-vacation-on-special-chars-message.sieve @@ -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 Alias "] "I'm on vacation. \"Hello, World!\" \\ escaped backslash"; diff --git a/tests/data/sieve-vacation-on-special-chars-subject.sieve b/tests/data/sieve-vacation-on-special-chars-subject.sieve index 686948c51d..2380c7ca95 100644 --- a/tests/data/sieve-vacation-on-special-chars-subject.sieve +++ b/tests/data/sieve-vacation-on-special-chars-subject.sieve @@ -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 Alias "] "I'm on vacation."; } } diff --git a/tests/data/sieve-vacation-on-subject-placeholder.sieve b/tests/data/sieve-vacation-on-subject-placeholder.sieve index 938ce0ee3b..6f8e0fd657 100644 --- a/tests/data/sieve-vacation-on-subject-placeholder.sieve +++ b/tests/data/sieve-vacation-on-subject-placeholder.sieve @@ -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 Alias "] "I'm on vacation."; } } diff --git a/tests/data/sieve-vacation-on.sieve b/tests/data/sieve-vacation-on.sieve index fe17540616..c4b3f35d6a 100644 --- a/tests/data/sieve-vacation-on.sieve +++ b/tests/data/sieve-vacation-on.sieve @@ -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 Alias "] "I'm on vacation."; } }