diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/id/FederatedIdMapperImpl.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/id/FederatedIdMapperImpl.kt index ad74dc56821..0b581a9b556 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/id/FederatedIdMapperImpl.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/id/FederatedIdMapperImpl.kt @@ -42,7 +42,7 @@ class FederatedIdMapperImpl internal constructor( private val sessionRepository: SessionRepository, ) : FederatedIdMapper { - private fun isFederationEnabled() = sessionRepository.isFederated(selfUserId).fold( + private suspend fun isFederationEnabled() = sessionRepository.isFederated(selfUserId).fold( { false }, { it } ) diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/session/SessionRepository.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/session/SessionRepository.kt index 2dea4940578..4d264cd8101 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/session/SessionRepository.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/session/SessionRepository.kt @@ -73,7 +73,7 @@ interface SessionRepository { suspend fun ssoId(userId: UserId): Either suspend fun updatePersistentWebSocketStatus(userId: UserId, isPersistentWebSocketEnabled: Boolean): Either suspend fun updateSsoIdAndScimInfo(userId: UserId, ssoId: SsoId?, managedBy: ManagedByDTO?): Either - fun isFederated(userId: UserId): Either + suspend fun isFederated(userId: UserId): Either suspend fun getAllValidAccountPersistentWebSocketStatus(): Either>> suspend fun persistentWebSocketStatus(userId: UserId): Either suspend fun cookieLabel(userId: UserId): Either @@ -195,7 +195,7 @@ internal class SessionDataSource internal constructor( accountsDAO.updateSsoIdAndScimInfo(userId.toDao(), idMapper.toSsoIdEntity(ssoId), managedBy?.toDao()) } - override fun isFederated(userId: UserId): Either = wrapStorageRequest { + override suspend fun isFederated(userId: UserId): Either = wrapStorageRequest { accountsDAO.isFederated(userId.toDao()) } diff --git a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/daokaliumdb/AccountsDAO.kt b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/daokaliumdb/AccountsDAO.kt index afec2a30e79..70c80ca2654 100644 --- a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/daokaliumdb/AccountsDAO.kt +++ b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/daokaliumdb/AccountsDAO.kt @@ -112,7 +112,7 @@ interface AccountsDAO { suspend fun allValidAccountList(): List fun observerValidAccountList(): Flow> suspend fun observeAllAccountList(): Flow> - fun isFederated(userIDEntity: UserIDEntity): Boolean? + suspend fun isFederated(userIDEntity: UserIDEntity): Boolean? suspend fun doesValidAccountExists(userIDEntity: UserIDEntity): Boolean suspend fun currentAccount(): AccountInfoEntity? fun observerCurrentAccount(): Flow @@ -189,8 +189,9 @@ internal class AccountsDAOImpl internal constructor( .flowOn(queriesContext) .mapToList() - override fun isFederated(userIDEntity: UserIDEntity): Boolean? = + override suspend fun isFederated(userIDEntity: UserIDEntity): Boolean? = withContext(queriesContext) { queries.isFederationEnabled(userIDEntity).executeAsOneOrNull() + } override suspend fun doesValidAccountExists(userIDEntity: UserIDEntity): Boolean = withContext(queriesContext) { queries.doesValidAccountExist(userIDEntity).executeAsOne()