Skip to content

Commit

Permalink
fix: wait for logout to be completed when handling user events [WPB-9…
Browse files Browse the repository at this point in the history
…689] [WPB-10310] 🍒 (#2919)

* fix: wait for logout to be completed when handling user events [WPB-9689] [WPB-10310] (#2914)

Co-authored-by: Vitor Hugo Schwaab <[email protected]>
Co-authored-by: Mohamad Jaara <[email protected]>

* trigger build

---------

Co-authored-by: Michał Saleniuk <[email protected]>
Co-authored-by: Vitor Hugo Schwaab <[email protected]>
Co-authored-by: Mohamad Jaara <[email protected]>
Co-authored-by: Michał Saleniuk <[email protected]>
  • Loading branch information
5 people authored Jul 30, 2024
1 parent 7d961c0 commit 21725e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ internal class UserEventReceiverImpl internal constructor(
return currentClientIdProvider().map { currentClientId ->
if (currentClientId == event.clientId) {
logger.logSuccess("info" to "CURRENT_CLIENT")
logout(LogoutReason.REMOVED_CLIENT)
logout(LogoutReason.REMOVED_CLIENT, waitUntilCompletes = true)
} else {
logger.logSuccess("info" to "OTHER_CLIENT")
}
Expand All @@ -148,7 +148,7 @@ internal class UserEventReceiverImpl internal constructor(
private suspend fun handleUserDelete(event: Event.User.UserDelete): Either<CoreFailure, Unit> {
val logger = kaliumLogger.createEventProcessingLogger(event)
return if (selfUserId == event.userId) {
logout(LogoutReason.DELETED_ACCOUNT)
logout(LogoutReason.DELETED_ACCOUNT, waitUntilCompletes = true)
Either.Right(Unit)
} else {
userRepository.markUserAsDeletedAndRemoveFromGroupConversations(event.userId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class UserEventReceiverTest {
eventReceiver.onEvent(event, TestEvent.liveDeliveryInfo)

coVerify {
arrangement.logoutUseCase.invoke(eq(LogoutReason.REMOVED_CLIENT), any())
arrangement.logoutUseCase.invoke(eq(LogoutReason.REMOVED_CLIENT), eq(true))
}.wasInvoked(exactly = once)
}

Expand Down Expand Up @@ -99,7 +99,7 @@ class UserEventReceiverTest {
eventReceiver.onEvent(event, TestEvent.liveDeliveryInfo)

coVerify {
arrangement.logoutUseCase.invoke(eq(LogoutReason.DELETED_ACCOUNT), any())
arrangement.logoutUseCase.invoke(eq(LogoutReason.DELETED_ACCOUNT), eq(true))
}.wasInvoked(exactly = once)
}

Expand Down

0 comments on commit 21725e7

Please sign in to comment.