Skip to content

Commit

Permalink
fixup! Fix/handle-duplicate-reminder
Browse files Browse the repository at this point in the history
Signed-off-by: hamza mahjoubi <[email protected]>
  • Loading branch information
hamza221 committed Apr 9, 2024
1 parent a29397d commit 318bd0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/Reminder/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct(IDBConnection $db,
*/
public function getRemindersToProcess():array {
$query = $this->db->getQueryBuilder();
$query->select(['cr.*', 'co.calendardata', 'c.displayname', 'c.principaluri'])
$query->select(['cr.*', 'co.calendardata', 'c.displayname', 'c.principaluri','cr.notification_date', 'cr.event_hash'])
->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'))
Expand Down
8 changes: 3 additions & 5 deletions apps/dav/lib/CalDAV/Reminder/ReminderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,13 @@ private function getRemindersForVAlarm(VAlarm $valarm,
*/
private function writeRemindersToDatabase(array $reminders): void {
$uniqueReminders = [];
$seen = [];
foreach ($reminders as $reminder) {
$key = $reminder['notification_date']. $reminder['event_hash'];
if(!isset($seen[$key])) {
$seen[$key] = true;
$uniqueReminders[] = $reminder;
if(!isset($uniqueReminders[$key])) {
$uniqueReminders[$key] = $reminder;
}
}
foreach ($reminders as $uniqueReminders) {
foreach (array_values($uniqueReminders) as $reminder) {
$this->backend->insertReminder(
(int) $reminder['calendar_id'],
(int) $reminder['object_id'],
Expand Down

0 comments on commit 318bd0f

Please sign in to comment.