diff --git a/lib/App.php b/lib/App.php index ab2c02c0..89edab40 100644 --- a/lib/App.php +++ b/lib/App.php @@ -43,6 +43,12 @@ public function notify(INotification $notification): void { } } + public function notifyDelete(string $user, ?int $id, ?INotification $notification): void { + $idAsArray = ($id !== null) ? [ $id ] : null; + $appName = ($notification !== null) ? $notification->getApp() : ""; + $this->push->pushDeleteToDevice($user, $idAsArray, $appName); + } + public function getLastInsertedId(): ?int { return $this->lastInsertedId; } diff --git a/lib/Controller/EndpointController.php b/lib/Controller/EndpointController.php index 5d282437..e7e480c2 100644 --- a/lib/Controller/EndpointController.php +++ b/lib/Controller/EndpointController.php @@ -229,7 +229,7 @@ public function deleteNotification(int $id): DataResponse { $deleted = $this->handler->deleteById($id, $this->getCurrentUser(), $notification); if ($deleted) { - $this->push->pushDeleteToDevice($this->getCurrentUser(), [$id], $notification->getApp()); + $this->manager->notifyDelete($this->getCurrentUser(), $id, $notification); } } catch (NotificationNotFoundException $e) { } @@ -255,7 +255,7 @@ public function deleteAllNotifications(): DataResponse { $deletedSomething = $this->handler->deleteByUser($this->getCurrentUser()); if ($deletedSomething) { - $this->push->pushDeleteToDevice($this->getCurrentUser(), null); + $this->manager->notifyDelete($this->getCurrentUser(), null, null); } if ($shouldFlush) {