Page MenuHomePhabricator

[lib] implement sending APNs notifs using Tunnelbroker
ClosedPublic

Authored by kamil on Fri, Jun 28, 5:51 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jul 1, 10:09 PM
Unknown Object (File)
Mon, Jul 1, 10:00 PM
Unknown Object (File)
Sat, Jun 29, 12:47 AM
Unknown Object (File)
Sat, Jun 29, 12:47 AM
Unknown Object (File)
Sat, Jun 29, 12:46 AM
Unknown Object (File)
Fri, Jun 28, 7:24 AM

Details

Summary

Client code to send notif.

Depends on D12616

Test Plan
try {
     const notif: TunnelbrokerAPNsNotif = {
       type: 'APNsNotif',
       headers: JSON.stringify({ 'apns-topic': 'app.comm' }),
       clientMessageID: uuid.v4(),
       deviceID: '[my device ID]',
       payload:
         '{"aps":{"alert":{"title":"your_title_here","body":"your_body_here"},"mutable-content":1}}',
     };
     await sendNotif(notif);
   } catch (e) {
     console.log(e);
   }

Testing this code multiple times with different TB configs and different headers.

Note: Not testing different payloads, code to create that is now being moved from keyserver so assuming it should work, Tunnelbroker does not modify notif itself. (cc. @marcin)

Diff Detail

Repository
rCOMM Comm
Branch
apns-tb
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

kamil held this revision as a draft.
kamil published this revision for review.Fri, Jun 28, 6:35 AM
lib/tunnelbroker/tunnelbroker-context.js
359–365

What is the point of all of this?

Why can't we just use sendMessageToDeviceRequest directly?

If it's a type issue, can we fix the type issue directly instead of making a duplicate function?

remove callback

lib/tunnelbroker/tunnelbroker-context.js
359–365

Initially, I wanted the param here to be APNsNotification, and based on that to build TunnelbrokerAPNsNotif (I wanted to avoid forcing building Tunnelbroker specific types when calling), but I was waiting to rebase this on D12429.

However, I discussed this today with @marcin and it'll be more convenient to leave it as it is right now - that being said we can use sendMessageToDeviceRequest directly.

lib/tunnelbroker/tunnelbroker-context.js
359–365

additionally, listed point 1 and 2 in ENG-8621 to improve naming here

bartek added inline comments.
lib/tunnelbroker/tunnelbroker-context.js
359–365

Isn't there a way to alias sendMessageToDeviceRequest()? Sth like

const sendNotif: (notif: TunnelbrokerAPNsNotif) => Promise<void>
  = sendMessageToDeviceRequest;

Edit: ah, that's what you did in the next revision 😉

This revision is now accepted and ready to land.Tue, Jul 2, 3:41 AM