Skip to content

Commit

Permalink
add error messages and detekt
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadJaara committed Jun 21, 2024
1 parent a297337 commit 9d906bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ internal class ScheduleNewAssetMessageUseCaseImpl(

private var outGoingAssetUploadJob: Job? = null

@Suppress("LongMethod")
@Suppress("LongMethod", "ReturnCount")
override suspend fun invoke(
conversationId: ConversationId,
assetDataPath: Path,
Expand All @@ -127,11 +127,14 @@ internal class ScheduleNewAssetMessageUseCaseImpl(
audioLengthInMs: Long
): ScheduleNewAssetMessageResult {
observeFileSharingStatus().first().also {
when(it.state) {
when (it.state) {
FileSharingStatus.Value.Disabled -> return ScheduleNewAssetMessageResult.Failure.DisabledByTeam
FileSharingStatus.Value.EnabledAll -> { /* no-op*/ }
is FileSharingStatus.Value.EnabledSome -> if(!validateAssetMimeTypeUseCase(assetMimeType, it.state.allowedType)) {
return ScheduleNewAssetMessageResult.Failure.RestrictedFileType
FileSharingStatus.Value.EnabledAll -> { /* no-op*/
}

is FileSharingStatus.Value.EnabledSome -> if (!validateAssetMimeTypeUseCase(assetMimeType, it.state.allowedType)) {
kaliumLogger.e("The asset message trying to be processed has invalid content data")
return ScheduleNewAssetMessageResult.Failure.RestrictedFileType
}
}
}
Expand Down Expand Up @@ -363,8 +366,8 @@ sealed interface ScheduleNewAssetMessageResult {
data class Success(val messageId: String) : ScheduleNewAssetMessageResult
sealed interface Failure : ScheduleNewAssetMessageResult {
data class Generic(val coreFailure: CoreFailure) : Failure
data object DisabledByTeam: Failure
data object RestrictedFileType: Failure
data object DisabledByTeam : Failure
data object RestrictedFileType : Failure
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
package com.wire.kalium.logic.feature.message

import com.wire.kalium.logic.cache.SelfConversationIdProvider
import com.wire.kalium.logic.configuration.UserConfigDataSource
import com.wire.kalium.logic.configuration.UserConfigRepository
import com.wire.kalium.logic.data.asset.AssetRepository
import com.wire.kalium.logic.data.client.ClientRepository
import com.wire.kalium.logic.data.client.MLSClientProvider
Expand Down Expand Up @@ -63,7 +61,6 @@ import com.wire.kalium.logic.feature.selfDeletingMessages.ObserveSelfDeletionTim
import com.wire.kalium.logic.feature.sessionreset.ResetSessionUseCase
import com.wire.kalium.logic.feature.sessionreset.ResetSessionUseCaseImpl
import com.wire.kalium.logic.feature.user.ObserveFileSharingStatusUseCase
import com.wire.kalium.logic.feature.user.ObserveFileSharingStatusUseCaseImpl
import com.wire.kalium.logic.sync.SyncManager
import com.wire.kalium.logic.util.MessageContentEncoder
import com.wire.kalium.util.KaliumDispatcher
Expand Down

0 comments on commit 9d906bb

Please sign in to comment.