Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add logs for reset session #1876

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.di.MapperProvider
import com.wire.kalium.logic.feature.ProteusClientProvider
import com.wire.kalium.logic.functional.fold
import com.wire.kalium.logic.kaliumLogger
import com.wire.kalium.util.KaliumDispatcher
import com.wire.kalium.util.KaliumDispatcherImpl
import kotlinx.coroutines.withContext
Expand Down Expand Up @@ -56,6 +57,7 @@ internal class BreakSessionUseCaseImpl internal constructor(
clientId: ClientId
): BreakSessionResult = withContext(dispatchers.io) {
return@withContext proteusClientProvider.getOrError().fold({
kaliumLogger.e("Failed to get proteus client for break session $it")
return@fold BreakSessionResult.Failure(it)
}, { proteusClient ->
val cryptoUserID = idMapper.toCryptoQualifiedIDId(userId)
Expand All @@ -65,6 +67,7 @@ internal class BreakSessionUseCaseImpl internal constructor(
)
// create a new session with the same session id
proteusClient.createSession(proteusClient.newLastPreKey(), cryptoSessionId)
kaliumLogger.e("Created new session for ${userId.toLogString()} with ${clientId.value}")
ohassine marked this conversation as resolved.
Show resolved Hide resolved
return@fold BreakSessionResult.Success
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.wire.kalium.logic.feature.ProteusClientProvider
import com.wire.kalium.logic.feature.message.SessionResetSender
import com.wire.kalium.logic.functional.flatMap
import com.wire.kalium.logic.functional.fold
import com.wire.kalium.logic.kaliumLogger
import com.wire.kalium.util.KaliumDispatcher
import com.wire.kalium.util.KaliumDispatcherImpl
import kotlinx.coroutines.withContext
Expand All @@ -41,6 +42,7 @@ import kotlinx.coroutines.withContext
interface ResetSessionUseCase {
suspend operator fun invoke(conversationId: ConversationId, userId: UserId, clientId: ClientId): ResetSessionResult
}

internal class ResetSessionUseCaseImpl internal constructor(
private val proteusClientProvider: ProteusClientProvider,
private val sessionResetSender: SessionResetSender,
Expand All @@ -54,6 +56,7 @@ internal class ResetSessionUseCaseImpl internal constructor(
clientId: ClientId
): ResetSessionResult = withContext(dispatchers.io) {
return@withContext proteusClientProvider.getOrError().fold({
kaliumLogger.e("Failed to get proteus client for session reset $it")
return@fold ResetSessionResult.Failure(it)
}, { proteusClient ->
val cryptoUserID = idMapper.toCryptoQualifiedIDId(userId)
Expand All @@ -68,14 +71,21 @@ internal class ResetSessionUseCaseImpl internal constructor(
userId = userId,
clientId = clientId
).flatMap {
kaliumLogger.e("Successfully sent session reset message")
messageRepository.markMessagesAsDecryptionResolved(
conversationId,
userId,
clientId
)
}.fold(
{ ResetSessionResult.Failure(it) },
{ ResetSessionResult.Success }
{
kaliumLogger.e("Failed to mark decryption error as resolved")
ResetSessionResult.Failure(it)
},
{
kaliumLogger.e("Successfully marked decryption error as resolved")
ResetSessionResult.Success
}
)

})
Expand Down
Loading