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

Unified push nextcloud notifications #2027

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/EndpointController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

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

I think you'd like to be always notified, not only when using the explicit delete?
But also e.g. when someone enters a Talk chat which marks all mention notifications read when they scroll down, Or when they join a call the call notification is removed.

This basically means you would want to be an NotificationApp yourself and listen to the markProcessed handling.

It's a bit weirdly abstracted and not clear (also not aware), but technically it is not required that the notifications app is not the only notification app. That's exactly why the API never operates based on IDs.
I guess you'd like to "be part of it" and basically want to act based on this app's notification id?
Similarly how we do it for the existing Push class:

foreach ($deleted as $user => $notifications) {
foreach ($notifications as $data) {
$this->push->pushDeleteToDevice((string)$user, [$data['id']], $data['app']);
}
}

Best idea that comes to my mind would be to emit an event in this app here with all deleted IDs?

}
} catch (NotificationNotFoundException $e) {
}
Expand All @@ -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) {
Expand Down