Skip to content

Commit 76b95d0

Browse files
committed
OperationRepo: when identity verification is on, do not process operations that have no valid JWT
1 parent eb525f4 commit 76b95d0

File tree

1 file changed

+27
-5
lines changed
  • OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/operations/impl

1 file changed

+27
-5
lines changed

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/operations/impl/OperationRepo.kt

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import com.onesignal.core.internal.startup.IStartableService
1111
import com.onesignal.core.internal.time.ITime
1212
import com.onesignal.debug.LogLevel
1313
import com.onesignal.debug.internal.logging.Logging
14+
import com.onesignal.user.internal.backend.IdentityConstants
15+
import com.onesignal.user.internal.identity.IdentityModelStore
1416
import com.onesignal.user.internal.operations.impl.states.NewRecordsState
1517
import kotlinx.coroutines.CompletableDeferred
1618
import kotlinx.coroutines.CoroutineScope
@@ -26,6 +28,7 @@ internal class OperationRepo(
2628
executors: List<IOperationExecutor>,
2729
private val _operationModelStore: OperationModelStore,
2830
private val _configModelStore: ConfigModelStore,
31+
private val _identityModelStore: IdentityModelStore,
2932
private val _time: ITime,
3033
private val _newRecordState: NewRecordsState,
3134
) : IOperationRepo, IStartableService {
@@ -359,13 +362,32 @@ internal class OperationRepo(
359362

360363
internal fun getNextOps(bucketFilter: Int): List<OperationQueueItem>? {
361364
return synchronized(queue) {
362-
val startingOp =
363-
queue.firstOrNull {
364-
it.operation.canStartExecute &&
365-
_newRecordState.canAccess(it.operation.applyToRecordId) &&
366-
it.bucket <= bucketFilter
365+
var startingOp: OperationQueueItem? = null
366+
// Search for the first operation that is qualified to execute
367+
for (queueItem in queue) {
368+
val operation = queueItem.operation
369+
370+
// Ensure the operation is in an executable state
371+
if (!operation.canStartExecute ||
372+
!_newRecordState.canAccess(
373+
operation.applyToRecordId,
374+
) || queueItem.bucket > bucketFilter
375+
) {
376+
continue
367377
}
368378

379+
// Ensure the operation does not have empty JWT if identity verification is on
380+
if (_configModelStore.model.useIdentityVerification &&
381+
operation.hasProperty(IdentityConstants.EXTERNAL_ID) &&
382+
_identityModelStore.model.jwtToken.isNullOrEmpty()
383+
) {
384+
continue
385+
}
386+
387+
startingOp = queueItem
388+
break
389+
}
390+
369391
if (startingOp != null) {
370392
queue.remove(startingOp)
371393
getGroupableOperations(startingOp)

0 commit comments

Comments
 (0)