@@ -12,6 +12,8 @@ import com.onesignal.core.internal.startup.IStartableService
12
12
import com.onesignal.core.internal.time.ITime
13
13
import com.onesignal.debug.LogLevel
14
14
import com.onesignal.debug.internal.logging.Logging
15
+ import com.onesignal.user.internal.backend.IdentityConstants
16
+ import com.onesignal.user.internal.identity.IdentityModelStore
15
17
import com.onesignal.user.internal.operations.impl.states.NewRecordsState
16
18
import kotlinx.coroutines.CompletableDeferred
17
19
import kotlinx.coroutines.CoroutineScope
@@ -27,6 +29,7 @@ internal class OperationRepo(
27
29
executors : List <IOperationExecutor >,
28
30
private val _operationModelStore : OperationModelStore ,
29
31
private val _configModelStore : ConfigModelStore ,
32
+ private val _identityModelStore : IdentityModelStore ,
30
33
private val _time : ITime ,
31
34
private val _newRecordState : NewRecordsState ,
32
35
) : IOperationRepo, IStartableService {
@@ -377,13 +380,32 @@ internal class OperationRepo(
377
380
378
381
internal fun getNextOps (bucketFilter : Int ): List <OperationQueueItem >? {
379
382
return synchronized(queue) {
380
- val startingOp =
381
- queue.firstOrNull {
382
- it.operation.canStartExecute &&
383
- _newRecordState .canAccess(it.operation.applyToRecordId) &&
384
- it.bucket <= bucketFilter
383
+ var startingOp: OperationQueueItem ? = null
384
+ // Search for the first operation that is qualified to execute
385
+ for (queueItem in queue) {
386
+ val operation = queueItem.operation
387
+
388
+ // Ensure the operation is in an executable state
389
+ if (! operation.canStartExecute ||
390
+ ! _newRecordState .canAccess(
391
+ operation.applyToRecordId,
392
+ ) || queueItem.bucket > bucketFilter
393
+ ) {
394
+ continue
385
395
}
386
396
397
+ // Ensure the operation does not have empty JWT if identity verification is on
398
+ if (_configModelStore .model.useIdentityVerification &&
399
+ operation.hasProperty(IdentityConstants .EXTERNAL_ID ) &&
400
+ _identityModelStore .model.jwtToken.isNullOrEmpty()
401
+ ) {
402
+ continue
403
+ }
404
+
405
+ startingOp = queueItem
406
+ break
407
+ }
408
+
387
409
if (startingOp != null ) {
388
410
queue.remove(startingOp)
389
411
getGroupableOperations(startingOp)
0 commit comments