Skip to content

Commit

Permalink
asset restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadJaara committed Jul 3, 2024
1 parent 509570a commit bd40547
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ internal class ScheduleNewAssetMessageUseCaseImpl(
observeFileSharingStatus().first().also {
when (it.state) {
FileSharingStatus.Value.Disabled -> return ScheduleNewAssetMessageResult.Failure.DisabledByTeam
FileSharingStatus.Value.EnabledAll -> { /* no-op*/
}
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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,11 @@ import com.wire.kalium.logic.feature.asset.ObserveAssetStatusesUseCase
import com.wire.kalium.logic.feature.asset.ObserveAssetStatusesUseCaseImpl
import com.wire.kalium.logic.feature.asset.ScheduleNewAssetMessageUseCase
import com.wire.kalium.logic.feature.asset.ScheduleNewAssetMessageUseCaseImpl
<<<<<<< HEAD
import com.wire.kalium.logic.feature.asset.UpdateAssetMessageTransferStatusUseCase
import com.wire.kalium.logic.feature.asset.UpdateAssetMessageTransferStatusUseCaseImpl
import com.wire.kalium.logic.feature.message.composite.SendButtonActionConfirmationMessageUseCase
=======
import com.wire.kalium.logic.feature.asset.UpdateAssetMessageDownloadStatusUseCase
import com.wire.kalium.logic.feature.asset.UpdateAssetMessageDownloadStatusUseCaseImpl
import com.wire.kalium.logic.feature.asset.UpdateAssetMessageUploadStatusUseCase
import com.wire.kalium.logic.feature.asset.UpdateAssetMessageUploadStatusUseCaseImpl
import com.wire.kalium.logic.feature.asset.ValidateAssetMimeTypeUseCase
import com.wire.kalium.logic.feature.asset.ValidateAssetMimeTypeUseCaseImpl
>>>>>>> 596eb022e3 (fix: asset restriction [WPB-9947] (#2831) (#2856) (#2861))
import com.wire.kalium.logic.feature.message.composite.SendButtonActionMessageUseCase
import com.wire.kalium.logic.feature.message.composite.SendButtonMessageUseCase
import com.wire.kalium.logic.feature.message.draft.GetMessageDraftUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ import com.wire.kalium.logic.data.sync.SlowSyncStatus
import com.wire.kalium.logic.feature.message.MessageSendFailureHandler
import com.wire.kalium.logic.feature.message.MessageSender
import com.wire.kalium.logic.feature.selfDeletingMessages.ObserveSelfDeletionTimerSettingsForConversationUseCase
<<<<<<< HEAD
=======
import com.wire.kalium.logic.data.message.SelfDeletionTimer
import com.wire.kalium.logic.feature.user.ObserveFileSharingStatusUseCase
>>>>>>> 596eb022e3 (fix: asset restriction [WPB-9947] (#2831) (#2856) (#2861))
import com.wire.kalium.logic.framework.TestAsset.dummyUploadedAssetId
import com.wire.kalium.logic.framework.TestAsset.mockedLongAssetData
import com.wire.kalium.logic.functional.Either
Expand All @@ -65,6 +61,7 @@ import io.mockative.matches
import io.mockative.mock
import io.mockative.once
import io.mockative.twice
import io.mockative.verify
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -253,11 +250,8 @@ class ScheduleNewAssetMessageUseCaseTest {
.withSelfDeleteTimer(SelfDeletionTimer.Disabled)
.withObserveMessageVisibility()
.withDeleteAssetLocally()
<<<<<<< HEAD
.withUpdateMessageAssetTransferStatus(UpdateTransferStatusResult.Success)
=======
.withObserveFileSharingStatusResult(FileSharingStatus.Value.EnabledAll)
>>>>>>> 596eb022e3 (fix: asset restriction [WPB-9947] (#2831) (#2856) (#2861))
.arrange()

// When
Expand All @@ -275,7 +269,6 @@ class ScheduleNewAssetMessageUseCaseTest {
advanceUntilIdle()

// Then
<<<<<<< HEAD
coVerify {
arrangement.persistMessage.invoke(any())
}.wasInvoked(exactly = twice)
Expand All @@ -288,23 +281,6 @@ class ScheduleNewAssetMessageUseCaseTest {
coVerify {
arrangement.messageSendFailureHandler.handleFailureAndUpdateMessageStatus(any(), any(), any(), any(), any())
}.wasInvoked(exactly = once)
=======
verify(arrangement.persistMessage)
.suspendFunction(arrangement.persistMessage::invoke)
.with(any())
.wasInvoked(exactly = twice)
verify(arrangement.assetDataSource)
.suspendFunction(arrangement.assetDataSource::uploadAndPersistPrivateAsset)
.with(any(), any(), any(), any())
.wasInvoked(exactly = once)
verify(arrangement.messageSender)
.suspendFunction(arrangement.messageSender::sendMessage)
.with(any())
.wasInvoked(exactly = once)
verify(arrangement.messageSendFailureHandler)
.suspendFunction(arrangement.messageSendFailureHandler::handleFailureAndUpdateMessageStatus)
.with(any(), any(), any(), any(), any())
.wasInvoked(exactly = once)
}

@Test
Expand Down Expand Up @@ -339,6 +315,10 @@ class ScheduleNewAssetMessageUseCaseTest {
advanceUntilIdle()

// Then
verify { arrangement.assetDataSource.persistAsset(TODO(), any(), any(), any(), any()) }
.wasInvoked(exactly = twice)

/*
verify(arrangement.persistMessage)
.suspendFunction(arrangement.persistMessage::invoke)
.with(
Expand All @@ -348,7 +328,8 @@ class ScheduleNewAssetMessageUseCaseTest {
}
)
.wasInvoked(exactly = twice)
>>>>>>> 596eb022e3 (fix: asset restriction [WPB-9947] (#2831) (#2856) (#2861))
*/
}

@Test
Expand Down Expand Up @@ -411,11 +392,8 @@ class ScheduleNewAssetMessageUseCaseTest {
.withSelfDeleteTimer(SelfDeletionTimer.Disabled)
.withObserveMessageVisibility()
.withDeleteAssetLocally()
<<<<<<< HEAD
.withUpdateMessageAssetTransferStatus(UpdateTransferStatusResult.Success)
=======
.withObserveFileSharingStatusResult(FileSharingStatus.Value.EnabledAll)
>>>>>>> 596eb022e3 (fix: asset restriction [WPB-9947] (#2831) (#2856) (#2861))
.arrange()

// When
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ sealed class ConversationRepository {
throw WebApplicationException("Instance ${instance.instanceId}: Could not get recent messages")
}

<<<<<<< HEAD
suspend fun getMessageReceipts(
instance: Instance,
conversationId: ConversationId,
Expand All @@ -408,10 +407,7 @@ sealed class ConversationRepository {
throw WebApplicationException("Instance ${instance.instanceId}: Could not get receipts from message")
}

@Suppress("LongParameterList", "LongMethod", "ThrowsCount")
=======
@Suppress("LongParameterList", "LongMethod", "ThrowsCount", "ComplexMethod")
>>>>>>> 596eb022e3 (fix: asset restriction [WPB-9947] (#2831) (#2856) (#2861))
suspend fun sendFile(
instance: Instance,
conversationId: ConversationId,
Expand Down

0 comments on commit bd40547

Please sign in to comment.