-
Notifications
You must be signed in to change notification settings - Fork 374
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 subscription/IAM not updated after upgrading from 5.2.0-beta or between 5.1.9 to 5.1.27 #2271
Conversation
2f929ee
to
405a778
Compare
53dccfc
to
25ff7b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some improvements could be made to MigrationRecovery but everything else looks good.
|
||
import com.onesignal.debug.internal.logging.Logging | ||
|
||
open class MigrationRecovery : IMigrationRecovery { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this an abstract class, as it isn't indented to be used directly, only extended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! This was actually designed but was playing with it as a base class.
override fun isInBadState(): Boolean { | ||
return false | ||
} | ||
|
||
override fun recover() { | ||
// left blank intentionally | ||
} | ||
|
||
override fun recoveryMessage(): String { | ||
return "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is made an abstract class then these 3 methods do not need to be defined here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the code and tested the change in the latest push.
92344ee
to
cfa6d8d
Compare
abstract override fun isInBadState(): Boolean | ||
|
||
abstract override fun recover() | ||
|
||
abstract override fun recoveryMessage(): String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines don't need to be here at all, these all implied and the complier doesn't require them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I have removed them in the latest push.
cfa6d8d
to
05fd286
Compare
Description
One Line Summary
Added a MigrationRecovery that detects and recovers a bad state that push sub ID is missing in the config store, caused by a bug in 5.2.0-beta or any version between 5.1.9-5.1.27.
Details
Motivation
5.2.0-beta and all versions between 5.1.9-5.1.27 have a specific logic for push subscription that depends on the result of a remote params fetch. It may cause the push sub ID to be missing from the config model if a postCreateDelay bug also happens that the app is closed within 5 seconds of first start.
Scope
A new MigrationRecovery that will check the status of the config model store and the subscription model store at the start() level.
OPTIONAL - Other
Interface IMigrationRecovery and a base class MigrationRecovery are added for the ease of creating more recovery in the future.
Testing
Unit testing
OPTIONAL - Explain unit tests added, if not clear in the code.
Manual testing
Step to reproduce:
Expected Behavior After the Fix:
After downgrade, the push subscription ID is correctly updated. All IAMs are displayed as expected.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is