Page MenuHomePhabricator

[native] refresh device token after receiving message from Tunnelbroker
ClosedPublic

Authored by kamil on Jul 29 2024, 4:08 AM.
Tags
None
Referenced Files
F3203861: D12916.id42875.diff
Sat, Nov 9, 8:31 PM
Unknown Object (File)
Wed, Nov 6, 11:03 PM
Unknown Object (File)
Sat, Oct 19, 8:24 AM
Unknown Object (File)
Fri, Oct 18, 9:46 PM
Unknown Object (File)
Fri, Oct 18, 9:46 PM
Unknown Object (File)
Fri, Oct 18, 9:46 PM
Unknown Object (File)
Fri, Oct 18, 9:46 PM
Unknown Object (File)
Oct 6 2024, 8:28 PM
Subscribers

Details

Summary

ENG-8498.

This is similar to the keyserver's BAD_DEVICE_TOKEN logic.

This is only about localToken which is set for every user, not touching tunnelbrokerToken so it shouldn't affect devices without CSAT and TB connection.

Depends on D12912

Test Plan

Make Tunnelbroker throw an error with an invalid device token, and test that a new token is uploaded (value in DDB changed). Additionally verified this using logs.

Diff Detail

Repository
rCOMM Comm
Branch
publish-device-token
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

kamil held this revision as a draft.
kamil published this revision for review.Aug 1 2024, 1:42 AM
kamil edited the summary of this revision. (Show Details)
kamil edited the test plan for this revision. (Show Details)
kamil edited the summary of this revision. (Show Details)
native/push/push-handler.react.js
445–459 ↗(On Diff #43013)

Nit: might be best to handle the simple case first and reduce indentation a bit

if (!this.props.loggedIn) {
  return;
}
if (Platform.OS === 'android') {
  await this.ensureAndroidPushNotifsEnabled();
  return;
}
if (Platform.OS !== 'ios') {
  // should not happen... we could consider an invariant here instead
  return;
}
let missingDeviceToken = !this.props.localToken;
if (!missingDeviceToken) {
  for (const keyserverID in this.props.deviceTokens) {
    const deviceToken = this.props.deviceTokens[keyserverID];
    if (deviceToken === null || deviceToken === undefined) {
      missingDeviceToken = true;
      break;
    }
  }
}
await requestIOSPushPermissions(missingDeviceToken);
This revision is now accepted and ready to land.Aug 2 2024, 1:42 AM