Page MenuHomePhabricator

[keyserver] Factor out importJSON
ClosedPublic

Authored by ashoat on May 12 2022, 6:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 16, 10:58 PM
Unknown Object (File)
Nov 18 2024, 3:09 PM
Unknown Object (File)
Nov 14 2024, 9:10 AM
Unknown Object (File)
Nov 14 2024, 9:10 AM
Unknown Object (File)
Nov 14 2024, 9:10 AM
Unknown Object (File)
Nov 13 2024, 10:51 AM
Unknown Object (File)
Nov 13 2024, 10:51 AM
Unknown Object (File)
Oct 28 2024, 3:03 AM

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
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 ↗(On Diff #12601)

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 ↗(On Diff #12601)

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 ↗(On Diff #12601)

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.