Skip to content

Commit 0c2afc5

Browse files
jinliu9508AR Abdul Azeez
andcommitted
fix: add new execution result for invalid login
Co-Authored-By: AR Abdul Azeez <abdul@onesignal.com>
1 parent d26af10 commit 0c2afc5

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ enum class ExecutionResult {
7777
*/
7878
FAIL_CONFLICT,
7979

80+
/**
81+
* Used in special create user case.
82+
* The operation failed due to invalid arguments (eg. restricted external ID is used.)
83+
* We should not retry the operation as the external ID should not be used again.
84+
*/
85+
FAIL_INVALID_LOGIN,
86+
8087
/**
8188
* Used in special create user case.
8289
* The operation failed due to a non-retryable error. Pause the operation repo

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ internal class OperationRepo(
270270
}
271271
ExecutionResult.FAIL_UNAUTHORIZED, // TODO: Need to provide callback for app to reset JWT. For now, fail with no retry.
272272
ExecutionResult.FAIL_NORETRY,
273+
ExecutionResult.FAIL_INVALID_LOGIN,
273274
ExecutionResult.FAIL_CONFLICT,
274275
-> {
275276
Logging.error("Operation execution failed without retry: $operations")

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/operations/impl/executors/LoginUserOperationExecutor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ internal class LoginUserOperationExecutor(
238238
NetworkUtils.ResponseStatusType.UNAUTHORIZED ->
239239
ExecutionResponse(ExecutionResult.FAIL_UNAUTHORIZED, retryAfterSeconds = ex.retryAfterSeconds)
240240
NetworkUtils.ResponseStatusType.INVALID ->
241-
ExecutionResponse(ExecutionResult.FAIL_NORETRY)
241+
ExecutionResponse(ExecutionResult.FAIL_INVALID_LOGIN)
242242
else ->
243243
ExecutionResponse(ExecutionResult.FAIL_PAUSE_OPREPO)
244244
}

OneSignalSDK/onesignal/core/src/test/java/com/onesignal/user/internal/operations/LoginUserOperationExecutorTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class LoginUserOperationExecutorTests : FunSpec({
163163
coVerify(exactly = 1) { mockUserBackendService.createUser(appId, mapOf(), any(), any()) }
164164
}
165165

166-
test("login anonymous user fails with no retry when hit with backend error 400") {
166+
test("login anonymous user fails with LOGIN_INVALID when hit with backend error 400") {
167167
// Given
168168
val mockUserBackendService = mockk<IUserBackendService>()
169169
coEvery { mockUserBackendService.createUser(any(), any(), any(), any()) } throws BackendException(400, "INVALID")
@@ -186,7 +186,7 @@ class LoginUserOperationExecutorTests : FunSpec({
186186
val response = loginUserOperationExecutor.execute(operations)
187187

188188
// Then
189-
response.result shouldBe ExecutionResult.FAIL_NORETRY
189+
response.result shouldBe ExecutionResult.FAIL_INVALID_LOGIN
190190
coVerify(exactly = 1) { mockUserBackendService.createUser(appId, mapOf(), any(), any()) }
191191
}
192192

0 commit comments

Comments
 (0)