From c9dbe18bbb030554a61516817ff7e9d96b80b671 Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Wed, 10 Apr 2024 19:21:10 -0400 Subject: [PATCH] don't re-create user on failed del alias attempts We incorrectly assumed that getting a 404 or a 410 from DELETE users/by/$aliasLabel/$aliasValue/identity/$aliasLabelToDelete means the user is gone. It could mean either the User and/or the Alias is gone, either way the end state is the same, the alias no longer exists on that User. If the User was really delete we will know on the next User operation, and that will handle the create User. This fixes a bug where the OperationRepo gets stuck in a loop trying to create the user over-and-over again if OneSignal.User.deleteAlias is called twice in a row with the same label. With the current SDK logic, the retrying was be done with a backoff, so retrying won't have had much of an impact on the OneSignal's backend load on 5.1.7 and later, but did on 5.0.0 to 5.1.6. --- .../impl/executors/IdentityOperationExecutor.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/operations/impl/executors/IdentityOperationExecutor.kt b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/operations/impl/executors/IdentityOperationExecutor.kt index 68ce3663d8..93b90faaa1 100644 --- a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/operations/impl/executors/IdentityOperationExecutor.kt +++ b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/operations/impl/executors/IdentityOperationExecutor.kt @@ -103,12 +103,10 @@ internal class IdentityOperationExecutor( NetworkUtils.ResponseStatusType.UNAUTHORIZED -> ExecutionResponse(ExecutionResult.FAIL_UNAUTHORIZED) NetworkUtils.ResponseStatusType.MISSING -> { - val operations = _buildUserService.getRebuildOperationsIfCurrentUser(lastOperation.appId, lastOperation.onesignalId) - if (operations == null) { - return ExecutionResponse(ExecutionResult.FAIL_NORETRY) - } else { - return ExecutionResponse(ExecutionResult.FAIL_RETRY, operations = operations) - } + // This means either the User or the Alias was already + // deleted, either way the end state is the same, the + // alias no longer exists on that User. + ExecutionResponse(ExecutionResult.SUCCESS) } } }