Browse code

BM-15104 Fix: send only one reminder when having an alarm on a recurrence exception

kladier authored on 08/08/2019 08:20:34
Showing 1 changed files
... ...
@@ -115,7 +115,7 @@ public class CalendarAlarmSupport implements IAlarmSupport<VEvent> {
115 115
 					VEventOccurrence occs = OccurrenceHelper.getOccurrence(event, expected);
116 116
 					// do not add reminder for event exceptions
117 117
 					// exceptions are processed below
118
-					if (occs != null && event.value.occurrence(expected) == null
118
+					if (occs != null && !hasAnyOccurenceMatching(event.value.occurrences, expected)
119 119
 							&& attends(occs, containerDescriptor.ownerDirEntryPath)) {
120 120
 						ret.add(net.bluemind.calendar.api.Reminder.create(ItemValue.create(event.uid, occs), valarm));
121 121
 					}
... ...
@@ -143,6 +143,10 @@ public class CalendarAlarmSupport implements IAlarmSupport<VEvent> {
143 143
 		return toReminder(ret);
144 144
 	}
145 145
 
146
+	private boolean hasAnyOccurenceMatching(List<VEventOccurrence> occurrences, BmDateTime expected) {
147
+		return occurrences.stream().anyMatch(occ -> occ.dtstart.equals(expected));
148
+	}
149
+
146 150
 	private boolean attends(VEventOccurrence occ, String dir) {
147 151
 		final String owner = "bm://" + dir;
148 152
 		return occ.attendees.isEmpty() || owner.equals(occ.organizer.dir) || occ.attendees.stream()