Skip to content

Fix unregistering pusher local error #2901

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

Merged
merged 3 commits into from
May 23, 2024

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented May 23, 2024

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Fixes #2895 by ignoring local error when unregistering a pusher (Firebase and UnifiedPush cases)

Base on the unitTestPush branch to be able to update the test, but the other PR will be merged first.

Motivation and context

Fixes #2895

Screenshots / GIFs

NA

Tests

  • Hard to test without hacking the code, but IRL this seems to happen.

Maybe @Xiretza may want to test the patch.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@bmarty bmarty requested a review from a team as a code owner May 23, 2024 09:34
@bmarty bmarty requested review from jmartinesp and removed request for a team May 23, 2024 09:34
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

📱 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/h4KUd1

Copy link

codecov bot commented May 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (feature/bma/unitTestPush@b8b66b3). Learn more about missing BASE report.
Report is 3 commits behind head on feature/bma/unitTestPush.

Additional details and impacted files
@@                     Coverage Diff                     @@
##             feature/bma/unitTestPush    #2901   +/-   ##
===========================================================
  Coverage                            ?   75.26%           
===========================================================
  Files                               ?     1550           
  Lines                               ?    36927           
  Branches                            ?     7149           
===========================================================
  Hits                                ?    27794           
  Misses                              ?     5398           
  Partials                            ?     3735           

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

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.

The code looks good, I just have a nitpick. However, I couldn't get NTFY working (maybe matrix.org is still rate limited?) so I couldn't really test it. I'll trust you on this one 👍 .

val userPushStore = userPushStoreFactory.getOrCreate(matrixClient.sessionId)
val currentPushProviderName = userPushStore.getPushProviderName()
val currentPushProvider = pushProviders.find { it.name == currentPushProviderName }
val currentDistributorValue = currentPushProvider?.getCurrentDistributor(matrixClient)?.value
if (currentPushProviderName != pushProvider.name || currentDistributorValue != distributor.value) {
// Unregister previous one if any
currentPushProvider?.unregister(matrixClient)
currentPushProvider
?.also { Timber.d("Unregistering previous push provider $currentPushProviderName/$currentDistributorValue") }
Copy link
Member

Choose a reason for hiding this comment

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

Nit: this could be logged before this call and not need an .also {}.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, not really since here currentPushProvider can still be null, so here ?. for the also is useful.
I agree that the code is a bit hard to follow, I tried to add some if(x (!= null) statement but it's getting worse.

Base automatically changed from feature/bma/unitTestPush to develop May 23, 2024 12:35
@bmarty bmarty merged commit 85c8a26 into develop May 23, 2024
22 checks passed
@bmarty bmarty deleted the feature/bma/fixUnregisteringPusherLocalError branch May 23, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Selecting ntfy as notification provider does not work
2 participants