Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Closes #8745 Remove OneTimeFxaPushReset from FxaPushSupportFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuie authored and mergify[bot] committed Nov 3, 2020
1 parent 5334759 commit c7645df
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,8 @@ internal class AccountObserver(
private val logger = Logger(AccountObserver::class.java.simpleName)
private val verificationDelegate = VerificationDelegate(context, push.config.disableRateLimit)
private val constellationObserver = ConstellationObserver(push, verificationDelegate)
private val pushReset = OneTimeFxaPushReset(context, push)

override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {

pushReset.resetSubscriptionIfNeeded(account)

// We need a new subscription only when we have a new account.
// The subscription is removed when an account logs out.
if (authType != AuthType.Existing && authType != AuthType.Recovered) {
Expand Down Expand Up @@ -335,44 +331,6 @@ internal class VerificationDelegate(
}
}

/**
* Resets the fxa push scope (and therefore push subscription) if it does not follow the new format.
*
* This is needed only for our existing push users and can be removed when we're more confident our users are
* all migrated.
*
* Implementation Notes: In order to support a new performance fix related to push and
* [FxaAccountManager] we need to use a new push scope format. This class checks if we have the old
* format, and removes it if so, thereby generating a new push scope with the new format.
*/
class OneTimeFxaPushReset(
private val context: Context,
private val pushFeature: AutoPushFeature
) {

/**
* Resets the push subscription if the old subscription format is used.
*/
fun resetSubscriptionIfNeeded(account: OAuthAccount) {
val pushScope = preference(context).getString(PREF_FXA_SCOPE, null) ?: return

if (pushScope.contains(FxaPushSupportFeature.PUSH_SCOPE_PREFIX)) {
return
}

val newPushScope = FxaPushSupportFeature.PUSH_SCOPE_PREFIX + pushScope

pushFeature.unsubscribe(pushScope)
pushFeature.subscribe(newPushScope) { subscription ->
CoroutineScope(Dispatchers.Main).launch {
account.deviceConstellation().setDevicePushSubscription(subscription.into())
}
}

preference(context).edit().putString(PREF_FXA_SCOPE, newPushScope).apply()
}
}

internal data class VerificationState(val timestamp: Long, val totalCount: Int)

@VisibleForTesting
Expand Down

This file was deleted.

3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ permalink: /changelog/
* [Gecko](https://github.com/mozilla-mobile/android-components/blob/master/buildSrc/src/main/java/Gecko.kt)
* [Configuration](https://github.com/mozilla-mobile/android-components/blob/master/.config.yml)

* **accounts-push**
* 🚒 Bug fixed [issue #8745](https://github.com/mozilla-mobile/android-components/issues/8745) - Remove OneTimeFxaPushReset from FxaPushSupportFeature
* ⚠️ **This is a breaking change** because the public API changes with the removal of the class.

# 65.0.0

Expand Down

0 comments on commit c7645df

Please sign in to comment.