Skip to content

Front/webpush#2663

Merged
nickvergessen merged 37 commits intonextcloud:masterfrom
p1gp1g:front/webpush
Mar 27, 2026
Merged

Front/webpush#2663
nickvergessen merged 37 commits intonextcloud:masterfrom
p1gp1g:front/webpush

Conversation

@p1gp1g
Copy link
Copy Markdown
Contributor

@p1gp1g p1gp1g commented Nov 28, 2025

This PR uses the new web push support (#2662) to get push notifications on the web application, even when nextcloud isn't opened in the browser.

It achieves 2 things:

  • it gives push notifications when nextcloud isn't opened: this is particularly useful for collaborative work, as nexcloud isn't always opened but we can expect to be notified anyway. (I won't miss call, polls, or events anymore)
  • it gives real time notifications, without the notify_push app (which adds a websocket support to nextcloud). It should reduce load on the server as the periodic fetch is reduce to once every 15min. When the server get a notification for a user, it sends it to the user through its push server (all modern browser are connected to a push server)

To work, this PR needs to add worker-src 'self' to the CSP by default:

https://github.com/nextcloud/server/blob/master/lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php#L62

-	protected $allowedWorkerSrcDomains = null;
+	protected $allowedWorkerSrcDomains = ["'self'"];

@p1gp1g p1gp1g mentioned this pull request Nov 28, 2025
@wrenix

This comment was marked as resolved.

@nickvergessen

This comment was marked as resolved.

@github-actions
Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@p1gp1g p1gp1g marked this pull request as ready for review February 12, 2026 11:20
@p1gp1g
Copy link
Copy Markdown
Contributor Author

p1gp1g commented Feb 12, 2026

I've rebased the PR on the master branch, and updated following some changes we did: apptype (array) => appTypes (String)

Comment thread src/NotificationsApp.vue Outdated
Comment thread src/NotificationsApp.vue Outdated
Comment thread src/NotificationsApp.vue
@Elsensee
Copy link
Copy Markdown

I really love this PR and I wanted WebPush support in Nextcloud for some time already, so I am super sorry for all this!

But another thing I noticed was, that you don’t seem to handle delete notifications at all? I am not even sure, how this could be properly handled. You could call getNotifications() and then close() but on Android this might still appear in the notification history. Also, when the tab is closed you must show a notification on push.
Alternatively, you could replace the notification with some silent notification with title "This notification has been deleted" and then quickly close() it, but I don’t know if that will actually work.

I assume, integrating UnifiedPush for the mobile apps will be a lot more straight forward as most logic should already be in place there. It’s just a shame, that you have to do all this manual legwork for browsers. 😅

@p1gp1g
Copy link
Copy Markdown
Contributor Author

p1gp1g commented Feb 12, 2026

I suppose this is a typo and you're not sorry for this ?

BTW, your help is very welcome, thanks. I will show a generic notification if we don't have the right content. You can also suggest code directly or open PR on my repo if you want :)

Regarding UnifiedPush: the implementation is already done, I've a few things to do following changes on the backend Pr :D

@Elsensee
Copy link
Copy Markdown

I just didn't want to come across as rude and complaining about a lot, especially since I am not affiliated with Nextcloud. :)

And nice, I will see what my time allows me to do on contributing. :)

I’m looking forward to the UnifiedPush implementation!

@p1gp1g
Copy link
Copy Markdown
Contributor Author

p1gp1g commented Feb 12, 2026

No problem, code review is done for that ! At the end we have a better solution

Comment thread public/service-worker.js
Copy link
Copy Markdown
Collaborator

@Antreesy Antreesy left a comment

Choose a reason for hiding this comment

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

From my POV frontend changes look fine. We tried it on a test instance, looks like working =)

regarding putting i file in /public and then having it on a root - if it's not an issue to have it on master branch, I can address it in a follow-up, it's not really related to webpush to block this PR from merging

Comment thread src/services/webPushService.js Outdated
Copy link
Copy Markdown
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

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

Otherwise good to go from API side

}

/**
* @return Int tokenId from IToken or ISession, negative in case of Session id, positive otherwise
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm a bit scare about this part.
I think I'd prefer having a second db field instead

Comment thread lib/Push.php
protected function validateToken(int $tokenId, int $maxAge): TokenValidation {
// This is a web session token
if ($tokenId < 0) {
return TokenValidation::VALID;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is it okay for a web session to be always valid?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They are Session and not Token, and $this->tokenProvider->getTokenById($tokenId) doesn't work for the session.

The idea is if the web push registration is removed from the browser, or expire because the user doesn't use their browser for some time, the push server will respond with 404 or 410, and the token will be wiped at this moment

Copy link
Copy Markdown
Collaborator

@Antreesy Antreesy left a comment

Choose a reason for hiding this comment

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

LGTM, pls maybe rebase and squash it up to 1-3 commits. Also double check DCO and other CI failures - NPM build we can trigger later separately

Comment thread src/services/webPushService.js Outdated
@p1gp1g p1gp1g force-pushed the front/webpush branch 3 times, most recently from 1239274 to 089b7cc Compare March 27, 2026 10:51
p1gp1g and others added 17 commits March 27, 2026 12:51
Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Signed-off-by: S1m <31284753+p1gp1g@users.noreply.github.com>
…eWorker

Signed-off-by: sim <git@sgougeon.fr>
Signed-off-by: sim <git@sgougeon.fr>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: sim <git@sgougeon.fr>
Signed-off-by: sim <git@sgougeon.fr>
Signed-off-by: sim <git@sgougeon.fr>
Signed-off-by: sim <git@sgougeon.fr>
Co-authored-by: Maksim Sukharev <antreesy.web@gmail.com>
Signed-off-by: S1m <31284753+p1gp1g@users.noreply.github.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: sim <git@sgougeon.fr>
Signed-off-by: sim <git@sgougeon.fr>
Co-authored-by: Maksim Sukharev <antreesy.web@gmail.com>
Signed-off-by: S1m <31284753+p1gp1g@users.noreply.github.com>
Signed-off-by: sim <git@sgougeon.fr>
@p1gp1g
Copy link
Copy Markdown
Contributor Author

p1gp1g commented Mar 27, 2026

Sorry, I missed another unconventional commit

@nickvergessen nickvergessen merged commit 95750ce into nextcloud:master Mar 27, 2026
45 of 47 checks passed
@nickvergessen
Copy link
Copy Markdown
Member

Will send a recompile PR afterwards

@Fuseteam

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants