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

Fix unified push unregister #3877

Merged
merged 8 commits into from
Nov 15, 2024
Merged

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Nov 15, 2024

Content

There was 2 user stories where the UnifiedPush subject was not properly removed:

  • it the user chooses to switch the the Firebase push provider
  • when the user logs out and is using UnifiedPush

The video below shows that after those 2 use cases, the ntfy app shows an empty list of topics. This was not the case before.

Motivation and context

Cleanup data and avoid ghost subscribed topic.

Screenshots / GIFs

UnifiedPushUnregister.mp4

Tests

  • Repeat the steps from 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

Copy link
Contributor

github-actions bot commented Nov 15, 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/equB5n

@bmarty bmarty added the PR-Bugfix For bug fix label Nov 15, 2024
Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82.90%. Comparing base (5d8d399) to head (f0aca00).
Report is 15 commits behind head on develop.

Files with missing lines Patch % Lines
.../android/libraries/push/impl/DefaultPushService.kt 87.50% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3877      +/-   ##
===========================================
+ Coverage    82.87%   82.90%   +0.02%     
===========================================
  Files         1784     1784              
  Lines        45090    45095       +5     
  Branches      5324     5326       +2     
===========================================
+ Hits         37369    37386      +17     
+ Misses        5857     5843      -14     
- Partials      1864     1866       +2     

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

@bmarty bmarty marked this pull request as ready for review November 15, 2024 14:36
@bmarty bmarty requested a review from a team as a code owner November 15, 2024 14:36
@bmarty bmarty requested review from jmartinesp and removed request for a team November 15, 2024 14:36
override fun cleanup(clientSecret: String) {
unifiedPushStore.storeUpEndpoint(clientSecret, null)
unifiedPushStore.storePushGateway(clientSecret, null)
UnifiedPush.unregisterApp(context, clientSecret)
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix 1: we need to provide clientSecret here to correctly un-register the app.

val currentPushProviderName = userPushStore.getPushProviderName()
val currentPushProvider = pushProviders.find { it.name == currentPushProviderName }
// Cleanup the current push provider. They may need the client secret, so delete the secret after.
currentPushProvider?.onSessionDeleted(sessionId)
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix 2: let the push provider do any necessary clean up when a session is removed.

Only after cleanup the stores related to the removed session.

Copy link

sonarcloud bot commented Nov 15, 2024

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.

LGTM, thanks for the fix!

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Nov 15, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Nov 15, 2024
@bmarty bmarty merged commit bb69e1e into develop Nov 15, 2024
29 checks passed
@bmarty bmarty deleted the feature/bma/fixUnifiedPushUnregister branch November 15, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Bugfix For bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants