Page MenuHomePhabricator

[keyserver] Factor out importJSON
ClosedPublic

Authored by ashoat on May 12 2022, 6:41 PM.
Tags
None
Referenced Files
F2151059: D4024.diff
Sun, Jun 30, 11:53 AM
F2148059: D4024.id.diff
Sun, Jun 30, 3:45 AM
F2145056: D4024.id13012.diff
Sat, Jun 29, 9:18 PM
F2142610: D4024.id13059.diff
Sat, Jun 29, 2:40 PM
F2142609: D4024.id13012.diff
Sat, Jun 29, 2:40 PM
F2142608: D4024.id12675.diff
Sat, Jun 29, 2:40 PM
F2142607: D4024.id12698.diff
Sat, Jun 29, 2:40 PM
F2142606: D4024.id12601.diff
Sat, Jun 29, 2:40 PM

Details

Summary

I was using copy-pasted code in several places, which is an anti-pattern. This diff should be a pure refactor.

Test Plan

Here's my plan:

  1. Test backup: create keyservers/facts/backups.json, update cronjob schedule to run right now, and make sure backup is created:
  2. Test GeoIP update: create keyservers/secrets/geoip_license.json, and then run cd keyserver && yarn update-geoip
  3. Test push notifs on both iOS and Android (see @palys-swm's instructions in a comment below)
  4. Test URLs (make sure keyserver works)

Diff Detail

Repository
rCOMM Comm
Branch
ashoat/dockerize_node
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

tomek requested changes to this revision.May 13 2022, 4:45 AM

Test push notifs (@palys-swm, any advice? I've never done this and I think you have)

On iOS we need to have comm_apn.p8 and comm_apn_config.json with "production": false. With these it should be possible to send notifications to a physical device in dev mode.
On Android, as far as I remember, the notifications work when comm_fcm_config.json is present, even on a simulator.

As to how test them, any scenario in which a notification is generated should work ok, e.g. when sending a message from user A to user B while the app is backgrounded.

keyserver/src/push/providers.js
30–54

It doesn't look like these two usages will work because in the previous version we were importing the files and then using .default when creating Provider / cert, but now importJSON takes the default and returns its value.

keyserver/src/utils/import-json.js
3–6

It is possible to avoid any by using a generic function, but I'm not sure if that's an improvement

This revision now requires changes to proceed.May 13 2022, 4:45 AM

Get rid of .default, still hasn't tested

Use generics instead of any

Still haven't tested

keyserver/src/push/providers.js
30–54

Good catch!

Finished testing!! Everything works

tomek added inline comments.
keyserver/src/utils/import-json.js
3–4 ↗(On Diff #12698)

Should we update the comment? We're returning ?T instead of any

This revision is now accepted and ready to land.May 23 2022, 2:29 AM
keyserver/src/utils/import-json.js
3–4 ↗(On Diff #12698)

Good call – this comment can just be removed

Removing code comment that is now irrelevant

This revision was automatically updated to reflect the committed changes.