Skip to content

Commit

Permalink
fixup! fixup! IamFetchReadyCondition Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
rgomezp committed Sep 25, 2024
1 parent 9480bd9 commit 601ec15
Showing 1 changed file with 1 addition and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.onesignal.common.consistency

import com.onesignal.common.consistency.enums.IamFetchRywTokenKey
import com.onesignal.common.consistency.impl.ConsistencyManager
import com.onesignal.common.consistency.models.ICondition
import com.onesignal.common.consistency.models.IConsistencyKeyEnum

Expand All @@ -21,25 +20,11 @@ class IamFetchReadyCondition(
override val id: String
get() = ID

override fun isMet(indexedTokens: Map<String, Map<IConsistencyKeyEnum, String?>>): Boolean {
override fun isMet(indexedTokens: Map<String, Map<IConsistencyKeyEnum, String>>): Boolean {
val tokenMap = indexedTokens[key] ?: return false
val userUpdateTokenSet = tokenMap[IamFetchRywTokenKey.USER] != null
val subscriptionUpdateTokenSet = tokenMap[IamFetchRywTokenKey.SUBSCRIPTION] != null

/**
* If the RYW token was not included in one of the 4 endpoints (PATCH & POST * user,
* subscription), we should resolve the condition so as to not block IAM fetch unnecessarily
* This can happen if there is a regression where we stop including the tokens in the res
* body or we turn off the feature temporarily
*/
val subscriptionOrUserTokenWasNotSet =
tokenMap[IamFetchRywTokenKey.SUBSCRIPTION] == ConsistencyManager.RYW_TOKEN_NOT_PROVIDED ||
tokenMap[IamFetchRywTokenKey.USER] == ConsistencyManager.RYW_TOKEN_NOT_PROVIDED

if (subscriptionOrUserTokenWasNotSet) {
return true
}

/**
* We always update the session count so we know we will have a userUpdateToken. We don't
* necessarily make a subscriptionUpdate call on every session. The following logic
Expand Down

0 comments on commit 601ec15

Please sign in to comment.