From 459b9ba1bd912fe8713dcd2f9dabe5629104d5a8 Mon Sep 17 00:00:00 2001 From: gavine99 Date: Wed, 4 Sep 2024 18:42:53 +1000 Subject: [PATCH 1/2] changes to enable 3rd party unified push app to send nextcloud notifications. Signed-off-by: Gavin Element --- lib/App.php | 6 ++++++ lib/Controller/EndpointController.php | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/App.php b/lib/App.php index ab2c02c0c..89edab405 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 5d282437e..e7e480c2d 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) { From e296bed689e6f661fabf57418dd35036187b1edf Mon Sep 17 00:00:00 2001 From: gavine99 Date: Fri, 6 Sep 2024 06:54:30 +1000 Subject: [PATCH 2/2] clean to lint standards. Signed-off-by: Gavin Element --- lib/App.php | 10 +++++----- lib/Controller/EndpointController.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/App.php b/lib/App.php index 89edab405..01a37308a 100644 --- a/lib/App.php +++ b/lib/App.php @@ -43,11 +43,11 @@ 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 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 e7e480c2d..d4f0d3281 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->manager->notifyDelete($this->getCurrentUser(), $id, $notification); + $this->manager->notifyDelete($this->getCurrentUser(), $id, $notification); } } catch (NotificationNotFoundException $e) { }