Page MenuHomePhabricator

[keyserver] Send WNS notifications
ClosedPublic

Authored by michal on Apr 3 2023, 3:59 AM.
Tags
None
Referenced Files
F3516427: D7284.diff
Sun, Dec 22, 2:28 PM
Unknown Object (File)
Sat, Dec 7, 8:31 PM
Unknown Object (File)
Sat, Dec 7, 8:31 PM
Unknown Object (File)
Fri, Dec 6, 9:55 PM
Unknown Object (File)
Thu, Nov 28, 5:57 AM
Unknown Object (File)
Nov 10 2024, 8:36 PM
Unknown Object (File)
Nov 10 2024, 8:36 PM
Unknown Object (File)
Nov 10 2024, 8:36 PM
Subscribers

Details

Summary

This diff enables keyserver to send the WNS notifications to windows devices. The actual wnsSinglePush is implemented based on this official quickstart tutorial.

Test Plan

Tested with the later diffs, with a Windows desktop client capable of accepting notifications. Send a notifications, test if it shows up on the windows machine. Check if the delivery appears in the notifications table in the db. Check if the device_token is removed if it's incorrect.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

michal requested review of this revision.Apr 3 2023, 4:15 AM
tomek requested changes to this revision.Apr 4 2023, 3:59 AM
tomek added inline comments.
keyserver/src/push/send.js
959 ↗(On Diff #24565)
keyserver/src/push/utils.js
295–315 ↗(On Diff #24565)

We can slightly improve performance by awaiting a little bit later. This will work because first requests should resolve earlier and don't need to wait for the later ones.

299–303 ↗(On Diff #24565)

Is there a length limit for WNS notification?

312 ↗(On Diff #24565)

It might be beneficial for readability to say that these are notif ids.

346 ↗(On Diff #24565)

Why do we send a request to deviceToken?

This revision now requires changes to proceed.Apr 4 2023, 3:59 AM

Improved error handling and added checking the domain of the url.

keyserver/src/push/utils.js
299–303 ↗(On Diff #24565)

According to these docs the length limit is 5000 bytes. I've added a warning when we exceed it (this is how we handle notifications for other providers).

346 ↗(On Diff #24565)

The Windows API returns a URL that we should send notifications to. According to the docs

The developer should never modify the channel URI and should consider it as a black-box string

Channel URI is the URL returned by the API and stored by the client in the device_token.

Also according to these docs:

It is important that the cloud service always ensures that the channel URI uses the domain “notify.windows.com”.

So I've added that check

tomek added inline comments.
keyserver/src/push/utils.js
293–295

These are urls containing tokens, so maybe we should rename them?

This revision is now accepted and ready to land.Apr 6 2023, 1:49 AM