Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate event email notifications #34909

Merged
merged 1 commit into from
Nov 4, 2022

Conversation

st3iny
Copy link
Member

@st3iny st3iny commented Nov 1, 2022

Fix #21370

This PR incorporates 2 fixes:

  1. VALARMs shouldn't be propagated to attendees via iTIP (not mandatory but recommended by RFC).
  2. Multiple email notifications are dispatched because there is no differentiation between when the owning user is the organizer of an event and when the owning user is an attendee.
  3. The email of the organizer was never extracted properly because the usage of strcasecmp($organizer->getValue(), 'mailto:') !== 0 was wrong. This lead to the Reply-To header not being set. -> Moved to a separate PR because it's not related.

How to test

Preparations

  1. Have at least 2 users.
  2. Configure your instance to be able to send emails.
  3. Enable instant event reminder sending: occ config:app:set dav sendEventRemindersMode --value occ
  4. Apply the following patch to make testing easier (by ignoring actual trigger date and time):
diff --git a/apps/dav/lib/CalDAV/Reminder/Backend.php b/apps/dav/lib/CalDAV/Reminder/Backend.php
index b0476e9594c..74a980d3f91 100644
--- a/apps/dav/lib/CalDAV/Reminder/Backend.php
+++ b/apps/dav/lib/CalDAV/Reminder/Backend.php
@@ -66,7 +66,6 @@ class Backend {
 		$query = $this->db->getQueryBuilder();
 		$query->select(['cr.*', 'co.calendardata', 'c.displayname', 'c.principaluri'])
 			->from('calendar_reminders', 'cr')
-			->where($query->expr()->lte('cr.notification_date', $query->createNamedParameter($this->timeFactory->getTime())))
 			->join('cr', 'calendarobjects', 'co', $query->expr()->eq('cr.object_id', 'co.id'))
 			->join('cr', 'calendars', 'c', $query->expr()->eq('cr.calendar_id', 'c.id'));
 		$stmt = $query->execute();

Routine

  1. Create a new event with at least one email reminder (trigger date and time don't matter).
  2. Add the other user as an attendee.
  3. Save the event.
  4. Trigger reminder sending: occ dav:send-event-reminders
  5. Observe that each users receives a single reminder email -> Duplicate emails fixed ✔️
  6. Login with the other user (which is an attendee).
  7. Observe that there are no reminders on the incoming event -> ALARMS shouldn't be propagated (recommended by the RFC) ✔️
  8. Add a "private" email reminder to my local copy.
  9. Save the event and trigger reminder sending again.
  10. Observe that only I (the attendee) receive an email -> Only the email reminders of organizers should be sent to all attendees ✔️

@st3iny st3iny added bug 2. developing Work in progress feature: caldav Related to CalDAV internals labels Nov 1, 2022
@st3iny st3iny self-assigned this Nov 1, 2022
@st3iny st3iny added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Nov 4, 2022
@st3iny st3iny marked this pull request as ready for review November 4, 2022 12:49
@st3iny st3iny requested a review from tcitworld November 4, 2022 12:49
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Code looks good and I can follow it for the most part 👍

Copy link
Contributor

@miaulalala miaulalala left a comment

Choose a reason for hiding this comment

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

❤️

@st3iny
Copy link
Member Author

st3iny commented Nov 4, 2022

/backport to stable25

@st3iny
Copy link
Member Author

st3iny commented Nov 4, 2022

/backport to stable24

@st3iny
Copy link
Member Author

st3iny commented Nov 4, 2022

/backport to stable23

@st3iny
Copy link
Member Author

st3iny commented Nov 4, 2022

/backport to stable22

@st3iny st3iny added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Nov 4, 2022
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
@st3iny st3iny force-pushed the fix/21370/duplicate-notifications-2 branch from 14f28c3 to 304b716 Compare November 4, 2022 15:25
@st3iny st3iny added this to the Nextcloud 26 milestone Nov 4, 2022
@PVince81 PVince81 merged commit 7ec9226 into master Nov 4, 2022
@PVince81 PVince81 deleted the fix/21370/duplicate-notifications-2 branch November 4, 2022 16:19
@st3iny
Copy link
Member Author

st3iny commented Nov 8, 2022

/backport to stable24

@st3iny
Copy link
Member Author

st3iny commented Nov 8, 2022

/backport to stable23

@st3iny
Copy link
Member Author

st3iny commented Nov 8, 2022

/backport to stable22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish bug feature: caldav Related to CalDAV internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calendar sends duplicate notifications if there is an additional attendee [$250]
5 participants