Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotate firebase token in case of error #3755

Merged
merged 4 commits into from
Oct 30, 2024
Merged

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Oct 30, 2024

Content

Add a quick fix for the troubleshoot notification test in case of PusherRejected error, which means that the token is unknown.

In this case, the quick fix will rotate the Firebase token.

Note: maybe later we will see if we can do the same thing for UnifiedPush provider.

Motivation and context

Closes #3752

Screenshots / GIFs

You can see in the video below that when clicking on QuickFix, the token is rotated.

FirebaseTokenRotation.mp4

Tests

  • @wrenix can you check if this is fixing your issue please?

Internally, this can be tested by patching the code and let DefaultPushService.testPush() throw a PushGatewayFailure.PusherRejected() (this is what I have done for the video above).

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

@bmarty bmarty requested a review from a team as a code owner October 30, 2024 11:04
@bmarty bmarty requested review from jmartinesp and removed request for a team October 30, 2024 11:04
@bmarty bmarty added the PR-Change For updates to an existing feature label Oct 30, 2024
Copy link
Contributor

github-actions bot commented Oct 30, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/oHbM5B

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried it yet, but the code LGTM, just a couple of suggestions.

override suspend fun delete() {
suspendCoroutine { continuation ->
// 'app should always check the device for a compatible Google Play services APK before accessing Google Play services features'
if (isPlayServiceAvailable.isAvailable()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a needed change, but an early return here with !isPlayServiceAvailable.isAvailable() might be more readable. Also, for the exception, maybe a throw Exception(...).also(Timber::e) might work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change. I am also wondering why we throw the exception here and we do not invoke continuation.resumeWithException(e) 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +18 to +20
/**
* This class delete the Firebase token and generate a new one.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comment should be in the interface instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks! 12f5839

Copy link

codecov bot commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 30.55556% with 50 lines in your changes missing coverage. Please review.

Project coverage is 83.03%. Comparing base (4a24668) to head (12f5839).
Report is 10 commits behind head on develop.

Files with missing lines Patch % Lines
...ies/pushproviders/firebase/FirebaseTokenDeleter.kt 0.00% 13 Missing ⚠️
...ries/pushproviders/firebase/FirebaseTokenGetter.kt 0.00% 13 Missing ⚠️
.../libraries/pushproviders/firebase/FirebaseStore.kt 0.00% 8 Missing ⚠️
...ies/pushproviders/firebase/FirebaseTokenRotator.kt 0.00% 7 Missing ⚠️
...braries/push/impl/troubleshoot/PushLoopbackTest.kt 60.00% 0 Missing and 2 partials ⚠️
...s/pushproviders/firebase/FirebaseTroubleshooter.kt 0.00% 2 Missing ⚠️
...s/pushproviders/firebase/IsPlayServiceAvailable.kt 0.00% 2 Missing ⚠️
...ndroid/libraries/pushproviders/api/PushProvider.kt 0.00% 1 Missing ⚠️
...ies/pushproviders/firebase/FirebasePushProvider.kt 66.66% 1 Missing ⚠️
...s/pushproviders/unifiedpush/UnifiedPushProvider.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3755      +/-   ##
===========================================
- Coverage    83.10%   83.03%   -0.07%     
===========================================
  Files         1771     1775       +4     
  Lines        44415    44461      +46     
  Branches      5207     5212       +5     
===========================================
+ Hits         36909    36920      +11     
- Misses        5674     5707      +33     
- Partials      1832     1834       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bmarty bmarty enabled auto-merge October 30, 2024 15:38
@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Oct 30, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Oct 30, 2024
Copy link

@bmarty bmarty merged commit 2fa85f7 into develop Oct 30, 2024
28 of 30 checks passed
@bmarty bmarty deleted the feature/bma/rotateFirebaseToken branch October 30, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Change For updates to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Push-Notification Option for recreate token if test failed
2 participants