From a666930eb06db6b8bad509a6e28a64132c707508 Mon Sep 17 00:00:00 2001 From: Mohamad Jaara Date: Mon, 8 Jul 2024 13:18:46 +0200 Subject: [PATCH 1/5] fix: asset restriction [WPB-9947] (#2831) (#2856) (#2862) (#3157) (cherry picked from commit 3213876be07fd3a562d29b927b794174a643b6ce) --- .../com/wire/android/ui/WireActivity.kt | 3 +- .../wire/android/ui/home/FeatureFlagState.kt | 22 ++++- .../conversations/ConversationMessageType.kt | 17 ++-- .../sendmessage/SendMessageViewModel.kt | 36 +++++-- .../sync/FeatureFlagNotificationViewModel.kt | 27 ++--- .../ui/settings/about/AboutThisAppScreen.kt | 4 +- .../ImportMediaAuthenticatedViewModel.kt | 78 ++++++++++++++- .../android/ui/sharing/ImportMediaScreen.kt | 15 ++- app/src/main/res/values/strings.xml | 4 +- .../MessageComposerViewModelArrangement.kt | 23 +++++ .../SendMessageViewModelArrangement.kt | 8 +- .../sendmessage/SendMessageViewModelTest.kt | 99 +++++++++++++++++-- .../FeatureFlagNotificationViewModelTest.kt | 12 +-- kalium | 2 +- 14 files changed, 276 insertions(+), 74 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/WireActivity.kt b/app/src/main/kotlin/com/wire/android/ui/WireActivity.kt index 95148361f5b..e072c5df087 100644 --- a/app/src/main/kotlin/com/wire/android/ui/WireActivity.kt +++ b/app/src/main/kotlin/com/wire/android/ui/WireActivity.kt @@ -91,6 +91,7 @@ import com.wire.android.ui.home.E2EICertificateRevokedDialog import com.wire.android.ui.home.E2EIRequiredDialog import com.wire.android.ui.home.E2EIResultDialog import com.wire.android.ui.home.E2EISnoozeDialog +import com.wire.android.ui.home.FeatureFlagState import com.wire.android.ui.home.appLock.LockCodeTimeManager import com.wire.android.ui.home.sync.FeatureFlagNotificationViewModel import com.wire.android.ui.legalhold.dialog.deactivated.LegalHoldDeactivatedDialog @@ -377,7 +378,7 @@ class WireActivity : AppCompatActivity() { } if (showFileSharingDialog) { FileRestrictionDialog( - isFileSharingEnabled = isFileSharingEnabledState, + isFileSharingEnabled = (isFileSharingState !is FeatureFlagState.FileSharingState.DisabledByTeam), hideDialogStatus = featureFlagNotificationViewModel::dismissFileSharingDialog ) } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/FeatureFlagState.kt b/app/src/main/kotlin/com/wire/android/ui/home/FeatureFlagState.kt index ed540612adf..ab39bcee7a1 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/FeatureFlagState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/FeatureFlagState.kt @@ -19,12 +19,12 @@ package com.wire.android.ui.home import com.wire.android.ui.home.messagecomposer.SelfDeletionDuration +import com.wire.kalium.logic.configuration.FileSharingStatus import kotlin.time.Duration data class FeatureFlagState( val showFileSharingDialog: Boolean = false, - val isFileSharingEnabledState: Boolean = true, - val fileSharingRestrictedState: SharingRestrictedState? = null, + val isFileSharingState: FileSharingState = FileSharingState.NoUser, val shouldShowGuestRoomLinkDialog: Boolean = false, val shouldShowE2eiCertificateRevokedDialog: Boolean = false, val shouldShowTeamAppLockDialog: Boolean = false, @@ -40,8 +40,12 @@ data class FeatureFlagState( val showCallEndedBecauseOfConversationDegraded: Boolean = false, val startGettingE2EICertificate: Boolean = false ) { - enum class SharingRestrictedState { - NONE, NO_USER, RESTRICTED_IN_TEAM + + sealed interface FileSharingState { + data object NoUser : FileSharingState + data object AllowAll : FileSharingState + data class AllowSome(val allowedList: List) : FileSharingState + data object DisabledByTeam : FileSharingState } data class E2EISnooze(val timeLeft: Duration) @@ -64,3 +68,13 @@ data class FeatureFlagState( data class Success(val certificate: String) : E2EIResult() } } + +fun FileSharingStatus.Value.toFeatureFlagState(): FeatureFlagState.FileSharingState { + return when (this) { + FileSharingStatus.Value.Disabled -> FeatureFlagState.FileSharingState.DisabledByTeam + FileSharingStatus.Value.EnabledAll -> FeatureFlagState.FileSharingState.AllowAll + is FileSharingStatus.Value.EnabledSome -> FeatureFlagState.FileSharingState.AllowSome( + allowedType + ) + } +} diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationMessageType.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationMessageType.kt index 2805ba03620..a9a76242a6c 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationMessageType.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationMessageType.kt @@ -23,12 +23,13 @@ import com.wire.android.model.SnackBarMessage import com.wire.android.util.ui.UIText sealed class ConversationSnackbarMessages(override val uiText: UIText) : SnackBarMessage { - object ErrorPickingAttachment : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_generic)) - object ErrorSendingAsset : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_sending_asset)) - object ErrorSendingImage : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_sending_image)) - object ErrorDownloadingAsset : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_downloading_asset)) - object ErrorOpeningAssetFile : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_opening_asset_file)) - object ErrorDeletingMessage : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_deleting_message)) + data object ErrorPickingAttachment : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_generic)) + data object ErrorSendingAsset : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_sending_asset)) + data object ErrorSendingImage : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_sending_image)) + data object ErrorDownloadingAsset : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_downloading_asset)) + data object ErrorOpeningAssetFile : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_opening_asset_file)) + data object ErrorDeletingMessage : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_deleting_message)) + data object ErrorAssetRestriction : ConversationSnackbarMessages(UIText.StringResource(R.string.restricted_asset_error_toast_message)) data class ErrorMaxAssetSize(val maxLimitInMB: Int) : ConversationSnackbarMessages(UIText.StringResource(R.string.error_conversation_max_asset_size_limit, maxLimitInMB)) @@ -42,6 +43,6 @@ sealed class MediaGallerySnackbarMessages(override val uiText: UIText) : SnackBa class OnImageDownloaded(val assetName: String? = null) : MediaGallerySnackbarMessages(UIText.StringResource(R.string.media_gallery_on_image_downloaded, assetName ?: "")) - object OnImageDownloadError : MediaGallerySnackbarMessages(UIText.StringResource(R.string.media_gallery_on_image_download_error)) - object DeletingMessageError : MediaGallerySnackbarMessages(UIText.StringResource(R.string.error_conversation_deleting_message)) + data object OnImageDownloadError : MediaGallerySnackbarMessages(UIText.StringResource(R.string.media_gallery_on_image_download_error)) + data object DeletingMessageError : MediaGallerySnackbarMessages(UIText.StringResource(R.string.error_conversation_deleting_message)) } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModel.kt index 60656a9ed52..ef6566f9831 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModel.kt @@ -42,6 +42,7 @@ import com.wire.android.ui.navArgs import com.wire.android.ui.sharing.SendMessagesSnackbarMessages import com.wire.android.util.SUPPORTED_AUDIO_MIME_TYPE import com.wire.android.util.ImageUtil +import com.wire.android.util.SUPPORTED_AUDIO_MIME_TYPE import com.wire.android.util.dispatchers.DispatcherProvider import com.wire.android.util.getAudioLengthInMs import com.wire.kalium.logic.CoreFailure @@ -338,18 +339,29 @@ class SendMessageViewModel @Inject constructor( } } - private fun Either.handleLegalHoldFailureAfterSendingMessage(conversationId: ConversationId) = + private fun Either.handleLegalHoldFailureAfterSendingMessage( + conversationId: ConversationId + ): Either = onFailure { it.handleLegalHoldFailureAfterSendingMessage(conversationId) } - private fun ScheduleNewAssetMessageResult.handleLegalHoldFailureAfterSendingMessage(conversationId: ConversationId) = let { - if (it is ScheduleNewAssetMessageResult.Failure) { - it.coreFailure.handleLegalHoldFailureAfterSendingMessage(conversationId) - } - when (this) { - is ScheduleNewAssetMessageResult.Failure -> Either.Left(coreFailure) - is ScheduleNewAssetMessageResult.Success -> Either.Right(Unit) + private fun ScheduleNewAssetMessageResult.handleLegalHoldFailureAfterSendingMessage( + conversationId: ConversationId + ): Either = + let { + when (this) { + is ScheduleNewAssetMessageResult.Success -> Either.Right(Unit) + ScheduleNewAssetMessageResult.Failure.DisabledByTeam, + ScheduleNewAssetMessageResult.Failure.RestrictedFileType -> { + onSnackbarMessage(ConversationSnackbarMessages.ErrorAssetRestriction) + Either.Left(null) + } + + is ScheduleNewAssetMessageResult.Failure.Generic -> { + this.coreFailure.handleLegalHoldFailureAfterSendingMessage(conversationId) + Either.Left(coreFailure) + } + } } - } fun retrySendingMessages(messageIdList: List, conversationId: ConversationId) { messageIdList.forEach { @@ -405,5 +417,11 @@ class SendMessageViewModel @Inject constructor( private companion object { const val MAX_LIMIT_MESSAGE_SEND = 20 + private fun beforeSendingMessage() { + viewState = viewState.copy(messageSent = false, inProgress = true) + } + + private fun Either.handleAfterMessageResult() { + viewState = viewState.copy(messageSent = this.isRight(), inProgress = false) } } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/sync/FeatureFlagNotificationViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/sync/FeatureFlagNotificationViewModel.kt index 0827edf82b4..a136ff5ff50 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/sync/FeatureFlagNotificationViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/sync/FeatureFlagNotificationViewModel.kt @@ -31,9 +31,9 @@ import com.wire.android.feature.DisableAppLockUseCase import com.wire.android.ui.home.FeatureFlagState import com.wire.android.ui.home.conversations.selfdeletion.SelfDeletionMapper.toSelfDeletionDuration import com.wire.android.ui.home.messagecomposer.SelfDeletionDuration +import com.wire.android.ui.home.toFeatureFlagState import com.wire.kalium.logic.CoreFailure import com.wire.kalium.logic.CoreLogic -import com.wire.kalium.logic.configuration.FileSharingStatus import com.wire.kalium.logic.data.message.TeamSelfDeleteTimer import com.wire.kalium.logic.data.sync.SyncState import com.wire.kalium.logic.data.user.UserId @@ -87,14 +87,14 @@ class FeatureFlagNotificationViewModel @Inject constructor( currentUserId = null appLogger.i("$TAG: Failure while getting current session") featureFlagState = FeatureFlagState( // no session, clear feature flag state to default and set NO_USER - fileSharingRestrictedState = FeatureFlagState.SharingRestrictedState.NO_USER + isFileSharingState = FeatureFlagState.FileSharingState.NoUser ) } currentSessionResult is CurrentSessionResult.Success && !currentSessionResult.accountInfo.isValid() -> { appLogger.i("$TAG: Invalid current session") featureFlagState = FeatureFlagState( // invalid session, clear feature flag state to default and set NO_USER - fileSharingRestrictedState = FeatureFlagState.SharingRestrictedState.NO_USER + isFileSharingState = FeatureFlagState.FileSharingState.NoUser ) } @@ -132,22 +132,11 @@ class FeatureFlagNotificationViewModel @Inject constructor( private suspend fun setFileSharingState(userId: UserId) { coreLogic.getSessionScope(userId).observeFileSharingStatus().collect { fileSharingStatus -> - fileSharingStatus.state.let { - // TODO: handle restriction when sending assets - val (fileSharingRestrictedState, state) = if (it is FileSharingStatus.Value.EnabledAll) { - FeatureFlagState.SharingRestrictedState.NONE to true - } else { - FeatureFlagState.SharingRestrictedState.RESTRICTED_IN_TEAM to false - } - - featureFlagState = featureFlagState.copy( - fileSharingRestrictedState = fileSharingRestrictedState, - isFileSharingEnabledState = state - ) - } - fileSharingStatus.isStatusChanged?.let { - featureFlagState = featureFlagState.copy(showFileSharingDialog = it) - } + val state: FeatureFlagState.FileSharingState = fileSharingStatus.state.toFeatureFlagState() + featureFlagState = featureFlagState.copy( + isFileSharingState = state, + showFileSharingDialog = fileSharingStatus.isStatusChanged ?: false + ) } } diff --git a/app/src/main/kotlin/com/wire/android/ui/settings/about/AboutThisAppScreen.kt b/app/src/main/kotlin/com/wire/android/ui/settings/about/AboutThisAppScreen.kt index c94102dd074..020d3723dc7 100644 --- a/app/src/main/kotlin/com/wire/android/ui/settings/about/AboutThisAppScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/settings/about/AboutThisAppScreen.kt @@ -54,8 +54,8 @@ import com.wire.android.util.ui.PreviewMultipleThemes @Destination @Composable fun AboutThisAppScreen( - viewModel: AboutThisAppViewModel = hiltViewModel(), - navigator: Navigator + navigator: Navigator, + viewModel: AboutThisAppViewModel = hiltViewModel() ) { val context = LocalContext.current AboutThisAppContent( diff --git a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt index b6b696b678a..2e171e70980 100644 --- a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt @@ -17,9 +17,11 @@ */ package com.wire.android.ui.sharing +import android.content.Context import android.content.Intent import android.net.Uri import android.os.Parcelable +import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.compose.foundation.text.input.TextFieldState import androidx.compose.runtime.Stable @@ -36,6 +38,8 @@ import com.wire.android.mapper.toUIPreview import com.wire.android.model.ImageAsset import com.wire.android.model.SnackBarMessage import com.wire.android.model.UserAvatarData +import com.wire.android.ui.home.conversations.ConversationSnackbarMessages +import com.wire.android.ui.home.conversations.model.AssetBundle import com.wire.android.ui.common.textfield.textAsFlow import com.wire.android.ui.home.conversations.search.DEFAULT_SEARCH_QUERY_DEBOUNCE import com.wire.android.ui.home.conversations.usecase.HandleUriAssetUseCase @@ -59,6 +63,7 @@ import com.wire.kalium.logic.feature.selfDeletingMessages.ObserveSelfDeletionTim import com.wire.kalium.logic.feature.selfDeletingMessages.PersistNewSelfDeletionTimerUseCase import com.wire.kalium.logic.feature.user.GetSelfUserUseCase import dagger.hilt.android.lifecycle.HiltViewModel +import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toPersistentList @@ -81,6 +86,7 @@ import javax.inject.Inject @OptIn(FlowPreview::class) @Suppress("LongParameterList", "TooManyFunctions") class ImportMediaAuthenticatedViewModel @Inject constructor( + @ApplicationContext private val context: Context, private val getSelf: GetSelfUserUseCase, private val userTypeMapper: UserTypeMapper, private val observeConversationListDetails: ObserveConversationListDetailsUseCase, @@ -301,6 +307,73 @@ class ImportMediaAuthenticatedViewModel @Inject constructor( } } + fun checkRestrictionsAndSendImportedMedia(onSent: (ConversationId) -> Unit) = + viewModelScope.launch(dispatchers.default()) { + val conversation = + importMediaState.selectedConversationItem.firstOrNull() ?: return@launch + val assetsToSend = importMediaState.importedAssets + val textToSend = importMediaState.importedText + + if (assetsToSend.size > MAX_LIMIT_MEDIA_IMPORT) { + onSnackbarMessage(ImportMediaSnackbarMessages.MaxAmountOfAssetsReached) + } else { + val jobs: MutableCollection = mutableListOf() + + textToSend?.let { + sendTextMessage( + conversationId = conversation.conversationId, + text = it + ) + } ?: assetsToSend.forEach { importedAsset -> + val isImage = importedAsset is ImportedMediaAsset.Image + val job = viewModelScope.launch { + sendAssetMessage( + conversationId = conversation.conversationId, + assetDataPath = importedAsset.assetBundle.dataPath, + assetName = importedAsset.assetBundle.fileName, + assetDataSize = importedAsset.assetBundle.dataSize, + assetMimeType = importedAsset.assetBundle.mimeType, + assetWidth = if (isImage) (importedAsset as ImportedMediaAsset.Image).width else 0, + assetHeight = if (isImage) (importedAsset as ImportedMediaAsset.Image).height else 0, + audioLengthInMs = getAudioLengthInMs( + dataPath = importedAsset.assetBundle.dataPath, + mimeType = importedAsset.assetBundle.mimeType, + ) + ).also { + handleError(it, conversation.conversationId) + } + } + jobs.add(job) + } + + jobs.joinAll() + withContext(dispatchers.main()) { + onSent(conversation.conversationId) + } + } + } + + private fun handleError(result: ScheduleNewAssetMessageResult, conversationId: ConversationId) { + when (result) { + is ScheduleNewAssetMessageResult.Success -> appLogger.d( + "Successfully imported asset message to conversationId=${conversationId.toLogString()}" + ) + + is ScheduleNewAssetMessageResult.Failure.Generic -> + appLogger.e( + "Failed to import asset message to conversationId=${conversationId.toLogString()}" + ) + + ScheduleNewAssetMessageResult.Failure.RestrictedFileType, + ScheduleNewAssetMessageResult.Failure.DisabledByTeam -> { + onSnackbarMessage(ConversationSnackbarMessages.ErrorAssetRestriction) + appLogger.e( + "Failed to import asset message to conversationId=${conversationId.toLogString()}" + ) + } + } + } + fun onNewConversationPicked(conversationId: ConversationId) = viewModelScope.launch { importMediaState = importMediaState.copy( selfDeletingTimer = observeSelfDeletionSettingsForConversation( @@ -342,7 +415,7 @@ class ImportMediaAuthenticatedViewModel @Inject constructor( } } - fun onSnackbarMessage(type: SnackBarMessage) = viewModelScope.launch { + private fun onSnackbarMessage(type: SnackBarMessage) = viewModelScope.launch { _infoMessage.emit(type) } } @@ -355,5 +428,6 @@ data class ImportMediaAuthenticatedState( val isImporting: Boolean = false, val shareableConversationListState: ShareableConversationListState = ShareableConversationListState(), val selectedConversationItem: List = emptyList(), - val selfDeletingTimer: SelfDeletionTimer = SelfDeletionTimer.Enabled(null) + val selfDeletingTimer: SelfDeletionTimer = SelfDeletionTimer.Enabled(null), + val assetSendError: AssetSendError? = null ) diff --git a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt index 74193563812..8d06d1f86c5 100644 --- a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt @@ -110,9 +110,8 @@ fun ImportMediaScreen( navigator: Navigator, featureFlagNotificationViewModel: FeatureFlagNotificationViewModel = hiltViewModel(), ) { - when (val fileSharingRestrictedState = - featureFlagNotificationViewModel.featureFlagState.fileSharingRestrictedState) { - FeatureFlagState.SharingRestrictedState.NO_USER -> { + when (val fileSharingRestrictedState = featureFlagNotificationViewModel.featureFlagState.isFileSharingState) { + FeatureFlagState.FileSharingState.NoUser -> { ImportMediaLoggedOutContent( fileSharingRestrictedState = fileSharingRestrictedState, navigateBack = navigator.finish, @@ -294,7 +293,7 @@ fun ImportMediaRegularContent( @Composable fun ImportMediaLoggedOutContent( - fileSharingRestrictedState: FeatureFlagState.SharingRestrictedState, + fileSharingRestrictedState: FeatureFlagState.FileSharingState, navigateBack: () -> Unit, openWireAction: () -> Unit, modifier: Modifier = Modifier @@ -322,7 +321,7 @@ fun ImportMediaLoggedOutContent( @Composable fun FileSharingRestrictedContent( internalPadding: PaddingValues, - sharingRestrictedState: FeatureFlagState.SharingRestrictedState, + sharingRestrictedState: FeatureFlagState.FileSharingState, openWireAction: () -> Unit, modifier: Modifier = Modifier ) { @@ -338,7 +337,7 @@ fun FileSharingRestrictedContent( .padding(horizontal = dimensions().spacing48x) ) { val textRes = - if (sharingRestrictedState == FeatureFlagState.SharingRestrictedState.NO_USER) { + if (sharingRestrictedState == FeatureFlagState.FileSharingState.NoUser) { R.string.file_sharing_restricted_description_no_users } else { R.string.file_sharing_restricted_description_by_team @@ -352,7 +351,7 @@ fun FileSharingRestrictedContent( Spacer(modifier = Modifier.height(dimensions().spacing16x)) - if (sharingRestrictedState == FeatureFlagState.SharingRestrictedState.NO_USER) { + if (sharingRestrictedState == FeatureFlagState.FileSharingState.NoUser) { WirePrimaryButton( onClick = openWireAction, text = stringResource(R.string.file_sharing_restricted_button_text_no_users), @@ -541,7 +540,7 @@ private fun SnackBarMessage( fun PreviewImportMediaScreenLoggedOut() { WireTheme { ImportMediaLoggedOutContent( - fileSharingRestrictedState = FeatureFlagState.SharingRestrictedState.NO_USER, + fileSharingRestrictedState = FeatureFlagState.FileSharingState.NoUser, navigateBack = {}, openWireAction = {}, ) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 08a6886819a..b04c5cb8323 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -998,7 +998,7 @@ Your username changed Send read receipts - If this is on, others can see if you read their messages. + If this is on, others can see if you read their messages. In group conversations, the group admin can overwrite this setting. Censor screenshots If this is ON, then the content of the messages will not be visible on the screenshot or screen recording. @@ -1443,4 +1443,6 @@ In group conversations, the group admin can overwrite this setting. No camera app found to complete this action. No gallery app found to complete this action. No file manager app found to complete this action. + + Sending of files is forbidden due to company restrictions diff --git a/app/src/test/kotlin/com/wire/android/ui/home/conversations/composer/MessageComposerViewModelArrangement.kt b/app/src/test/kotlin/com/wire/android/ui/home/conversations/composer/MessageComposerViewModelArrangement.kt index ace2deec313..b80f5d48c29 100644 --- a/app/src/test/kotlin/com/wire/android/ui/home/conversations/composer/MessageComposerViewModelArrangement.kt +++ b/app/src/test/kotlin/com/wire/android/ui/home/conversations/composer/MessageComposerViewModelArrangement.kt @@ -174,6 +174,29 @@ internal class MessageComposerViewModelArrangement { ) } + fun withStoredAsset(dataPath: Path, dataContent: ByteArray) = apply { + fakeKaliumFileSystem.sink(dataPath).buffer().use { + it.write(dataContent) + } + } + + fun withSuccessfulSendTypingEvent() = apply { + coEvery { + sendTypingEvent( + any(), + any() + ) + } returns Unit + } + + fun withObserveSelfDeletingStatus(expectedSelfDeletionTimer: SelfDeletionTimer) = apply { + coEvery { observeConversationSelfDeletionStatus(conversationId, true) } returns flowOf(expectedSelfDeletionTimer) + } + + fun withPersistSelfDeletionStatus() = apply { + coEvery { persistSelfDeletionStatus(any(), any()) } returns Unit + } + fun withSaveDraftMessage() = apply { coEvery { saveMessageDraftUseCase(any()) } returns Unit } diff --git a/app/src/test/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModelArrangement.kt b/app/src/test/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModelArrangement.kt index 0c4cd6c357e..5e3c9d2c96c 100644 --- a/app/src/test/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModelArrangement.kt +++ b/app/src/test/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModelArrangement.kt @@ -18,7 +18,6 @@ package com.wire.android.ui.home.conversations.sendmessage -import androidx.lifecycle.SavedStateHandle import com.wire.android.config.TestDispatcherProvider import com.wire.android.config.mockUri import com.wire.android.framework.FakeKaliumFileSystem @@ -79,9 +78,6 @@ internal class SendMessageViewModelArrangement { coEvery { observeConversationUnderLegalHoldNotified(any()) } returns flowOf(true) } - @MockK - private lateinit var savedStateHandle: SavedStateHandle - @MockK lateinit var sendTextMessage: SendTextMessageUseCase @@ -173,7 +169,7 @@ internal class SendMessageViewModelArrangement { } } - fun withSuccessfulSendAttachmentMessage() = apply { + fun withSendAttachmentMessageResult(result: ScheduleNewAssetMessageResult) = apply { coEvery { sendAssetMessage( any(), @@ -185,7 +181,7 @@ internal class SendMessageViewModelArrangement { any(), any() ) - } returns ScheduleNewAssetMessageResult.Success("some-message-id") + } returns result } fun withSuccessfulSendTextMessage() = apply { diff --git a/app/src/test/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModelTest.kt b/app/src/test/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModelTest.kt index b3694b310f5..90b62d05ceb 100644 --- a/app/src/test/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModelTest.kt +++ b/app/src/test/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModelTest.kt @@ -35,6 +35,7 @@ import com.wire.kalium.logic.data.asset.AttachmentType import com.wire.kalium.logic.data.conversation.Conversation import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.failure.LegalHoldEnabledForConversationFailure +import com.wire.kalium.logic.feature.asset.ScheduleNewAssetMessageResult import io.mockk.coVerify import io.mockk.verify import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -65,7 +66,7 @@ class SendMessageViewModelTest { ) val (arrangement, viewModel) = SendMessageViewModelArrangement() .withSuccessfulViewModelInit() - .withSuccessfulSendAttachmentMessage() + .withSendAttachmentMessageResult(ScheduleNewAssetMessageResult.Success("some-message-id")) .withHandleUriAsset(HandleUriAssetUseCase.Result.Success(mockedAttachment)) .arrange() @@ -102,7 +103,7 @@ class SendMessageViewModelTest { val (arrangement, viewModel) = SendMessageViewModelArrangement() .withSuccessfulViewModelInit() .withStoredAsset(assetPath, assetContent) - .withSuccessfulSendAttachmentMessage() + .withSendAttachmentMessageResult(ScheduleNewAssetMessageResult.Success("some-message-id")) .withHandleUriAsset(HandleUriAssetUseCase.Result.Success(mockedAttachment)) .arrange() @@ -130,7 +131,7 @@ class SendMessageViewModelTest { // Given val (arrangement, viewModel) = SendMessageViewModelArrangement() .withSuccessfulViewModelInit() - .withSuccessfulSendAttachmentMessage() + .withSendAttachmentMessageResult(ScheduleNewAssetMessageResult.Success("some-message-id")) .arrange() val mockedAttachment = null @@ -166,7 +167,7 @@ class SendMessageViewModelTest { ) val (arrangement, viewModel) = SendMessageViewModelArrangement() .withSuccessfulViewModelInit() - .withSuccessfulSendAttachmentMessage() + .withSendAttachmentMessageResult(ScheduleNewAssetMessageResult.Success("some-message-id")) .withHandleUriAsset(HandleUriAssetUseCase.Result.Failure.AssetTooLarge(mockedAttachment, 25)) .arrange() val mockedMessageBundle = ComposableMessageBundle.UriPickedBundle( @@ -208,7 +209,7 @@ class SendMessageViewModelTest { ) val (arrangement, viewModel) = SendMessageViewModelArrangement() .withSuccessfulViewModelInit() - .withSuccessfulSendAttachmentMessage() + .withSendAttachmentMessageResult(ScheduleNewAssetMessageResult.Success("some-message-id")) .withHandleUriAsset(HandleUriAssetUseCase.Result.Failure.AssetTooLarge(mockedAttachment, limit)) .arrange() val mockedMessageBundle = ComposableMessageBundle.UriPickedBundle( @@ -241,7 +242,7 @@ class SendMessageViewModelTest { // Given val (arrangement, viewModel) = SendMessageViewModelArrangement() .withSuccessfulViewModelInit() - .withSuccessfulSendAttachmentMessage() + .withSendAttachmentMessageResult(ScheduleNewAssetMessageResult.Success("some-message-id")) .withHandleUriAsset(HandleUriAssetUseCase.Result.Failure.Unknown) .arrange() val mockedMessageBundle = ComposableMessageBundle.UriPickedBundle( @@ -303,7 +304,7 @@ class SendMessageViewModelTest { val (arrangement, viewModel) = SendMessageViewModelArrangement() .withSuccessfulViewModelInit() .withStoredAsset(assetPath, assetContent) - .withSuccessfulSendAttachmentMessage() + .withSendAttachmentMessageResult(ScheduleNewAssetMessageResult.Success("some-message-id")) .withHandleUriAsset(HandleUriAssetUseCase.Result.Success(mockedAttachment)) .arrange() @@ -564,6 +565,90 @@ class SendMessageViewModelTest { assertEquals(SureAboutMessagingDialogState.Hidden, viewModel.sureAboutMessagingDialogState) } + @Test + fun `given mimeType is DisabledByTeam, when trying to send, then show message to user`() = + runTest { + // Given + val (arrangement, viewModel) = SendMessageViewModelArrangement() + .withSuccessfulViewModelInit() + .withSendAttachmentMessageResult(ScheduleNewAssetMessageResult.Failure.DisabledByTeam) + .withHandleUriAsset(HandleUriAssetUseCase.Result.Failure.Unknown) + .arrange() + + val mockedAttachment = AssetBundle( + "key", + "application/pdf", + "some-data-path".toPath(), + 1L, + "mocked_file.pdf", + AttachmentType.GENERIC_FILE + ) + + // When + viewModel.infoMessage.test { + viewModel.sendAttachment(mockedAttachment, conversationId) + + // Then + coVerify(exactly = 1) { + arrangement.sendAssetMessage.invoke( + any(), + any(), + any(), + any(), + any(), + any(), + any(), + any() + ) + } + assertEquals(ConversationSnackbarMessages.ErrorAssetRestriction, awaitItem()) + } + } + + @Test + fun `given mimeType is RestrictedFileType, when trying to send, then show message to user`() = + runTest { + val assetPath = "mocked-asset-data-path".toPath() + val assetContent = "some-dummy-audio".toByteArray() + + val mockedAttachment = AssetBundle( + "key", + "application/pdf", + "some-data-path".toPath(), + 1L, + "mocked_file.pdf", + AttachmentType.GENERIC_FILE + ) + + // Given + val (arrangement, viewModel) = SendMessageViewModelArrangement() + .withSuccessfulViewModelInit() + .withStoredAsset(assetPath, assetContent) + .withHandleUriAsset(HandleUriAssetUseCase.Result.Success(mockedAttachment)) + .withSendAttachmentMessageResult(ScheduleNewAssetMessageResult.Failure.RestrictedFileType) + .arrange() + + // When + viewModel.infoMessage.test { + viewModel.sendAttachment(mockedAttachment, conversationId) + + // Then + coVerify(exactly = 1) { + arrangement.sendAssetMessage.invoke( + any(), + any(), + any(), + any(), + any(), + any(), + any(), + any() + ) + } + assertEquals(ConversationSnackbarMessages.ErrorAssetRestriction, awaitItem()) + } + } + companion object { val conversationId: ConversationId = ConversationId("some-dummy-value", "some.dummy.domain") } diff --git a/app/src/test/kotlin/com/wire/android/ui/home/sync/FeatureFlagNotificationViewModelTest.kt b/app/src/test/kotlin/com/wire/android/ui/home/sync/FeatureFlagNotificationViewModelTest.kt index 8e71c6d0401..7665124d460 100644 --- a/app/src/test/kotlin/com/wire/android/ui/home/sync/FeatureFlagNotificationViewModelTest.kt +++ b/app/src/test/kotlin/com/wire/android/ui/home/sync/FeatureFlagNotificationViewModelTest.kt @@ -69,8 +69,8 @@ class FeatureFlagNotificationViewModelTest { advanceUntilIdle() assertEquals( - expected = FeatureFlagState.SharingRestrictedState.NO_USER, - actual = viewModel.featureFlagState.fileSharingRestrictedState + expected = FeatureFlagState.FileSharingState.NoUser, + actual = viewModel.featureFlagState.isFileSharingState ) } @@ -83,8 +83,8 @@ class FeatureFlagNotificationViewModelTest { advanceUntilIdle() assertEquals( - expected = FeatureFlagState.SharingRestrictedState.RESTRICTED_IN_TEAM, - actual = viewModel.featureFlagState.fileSharingRestrictedState + expected = FeatureFlagState.FileSharingState.DisabledByTeam, + actual = viewModel.featureFlagState.isFileSharingState ) } @@ -114,8 +114,8 @@ class FeatureFlagNotificationViewModelTest { advanceUntilIdle() assertEquals( - expected = FeatureFlagState.SharingRestrictedState.NONE, - actual = viewModel.featureFlagState.fileSharingRestrictedState + expected = FeatureFlagState.FileSharingState.AllowAll, + actual = viewModel.featureFlagState.isFileSharingState ) } diff --git a/kalium b/kalium index c01866c6446..a89ab590d62 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit c01866c6446e601a3dd87378fc476d61e61dc6c4 +Subproject commit a89ab590d62a7f0d80ad80dab92014113132e68b From 870eaa63bbae341357aa1d63e0a63b1cd1fcb138 Mon Sep 17 00:00:00 2001 From: MohamadJaara Date: Mon, 8 Jul 2024 16:37:35 +0200 Subject: [PATCH 2/5] fix plus icon disabled --- .../composer/MessageComposerViewModel.kt | 6 +-- .../sendmessage/SendMessageViewModel.kt | 7 --- .../IsFileSharingEnabledViewModel.kt | 7 ++- .../ImportMediaAuthenticatedViewModel.kt | 50 +------------------ .../android/ui/sharing/ImportMediaScreen.kt | 12 ++--- .../MessageComposerViewModelArrangement.kt | 23 --------- .../SendMessageViewModelArrangement.kt | 4 ++ default.json | 2 +- 8 files changed, 18 insertions(+), 93 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/composer/MessageComposerViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/composer/MessageComposerViewModel.kt index 09d12144703..ec40a96c399 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/composer/MessageComposerViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/composer/MessageComposerViewModel.kt @@ -136,6 +136,7 @@ class MessageComposerViewModel @Inject constructor( } } } + else -> flowOf(InteractionAvailability.DISABLED) } } @@ -167,13 +168,12 @@ class MessageComposerViewModel @Inject constructor( } private fun setFileSharingStatus() { - // TODO: handle restriction when sending assets viewModelScope.launch { messageComposerViewState.value = when (isFileSharingEnabled().state) { - FileSharingStatus.Value.Disabled, - is FileSharingStatus.Value.EnabledSome -> + FileSharingStatus.Value.Disabled -> messageComposerViewState.value.copy(isFileSharingEnabled = false) + is FileSharingStatus.Value.EnabledSome, FileSharingStatus.Value.EnabledAll -> messageComposerViewState.value.copy(isFileSharingEnabled = true) } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModel.kt index ef6566f9831..3ab0e70b356 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModel.kt @@ -414,14 +414,7 @@ class SendMessageViewModel @Inject constructor( } sureAboutMessagingDialogState = SureAboutMessagingDialogState.Hidden } - private companion object { const val MAX_LIMIT_MESSAGE_SEND = 20 - private fun beforeSendingMessage() { - viewState = viewState.copy(messageSent = false, inProgress = true) - } - - private fun Either.handleAfterMessageResult() { - viewState = viewState.copy(messageSent = this.isRight(), inProgress = false) } } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/attachments/IsFileSharingEnabledViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/attachments/IsFileSharingEnabledViewModel.kt index fbb54b26201..c0a2ebbefb0 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/attachments/IsFileSharingEnabledViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/attachments/IsFileSharingEnabledViewModel.kt @@ -48,12 +48,11 @@ class IsFileSharingEnabledViewModelImpl @Inject constructor( getIsFileSharingEnabled() } - // TODO: handle restriction when sending assets private fun getIsFileSharingEnabled() = viewModelScope.launch { state = when (isFileSharingEnabledUseCase().state) { - FileSharingStatus.Value.Disabled, - is FileSharingStatus.Value.EnabledSome -> false - FileSharingStatus.Value.EnabledAll -> true + FileSharingStatus.Value.Disabled-> false + FileSharingStatus.Value.EnabledAll, + is FileSharingStatus.Value.EnabledSome -> true } } } diff --git a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt index 2e171e70980..946a92673be 100644 --- a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt @@ -58,6 +58,7 @@ import com.wire.kalium.logic.data.conversation.ConversationDetails import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.data.message.SelfDeletionTimer import com.wire.kalium.logic.data.message.SelfDeletionTimer.Companion.SELF_DELETION_LOG_TAG +import com.wire.kalium.logic.feature.asset.ScheduleNewAssetMessageResult import com.wire.kalium.logic.feature.conversation.ObserveConversationListDetailsUseCase import com.wire.kalium.logic.feature.selfDeletingMessages.ObserveSelfDeletionTimerSettingsForConversationUseCase import com.wire.kalium.logic.feature.selfDeletingMessages.PersistNewSelfDeletionTimerUseCase @@ -307,52 +308,6 @@ class ImportMediaAuthenticatedViewModel @Inject constructor( } } - fun checkRestrictionsAndSendImportedMedia(onSent: (ConversationId) -> Unit) = - viewModelScope.launch(dispatchers.default()) { - val conversation = - importMediaState.selectedConversationItem.firstOrNull() ?: return@launch - val assetsToSend = importMediaState.importedAssets - val textToSend = importMediaState.importedText - - if (assetsToSend.size > MAX_LIMIT_MEDIA_IMPORT) { - onSnackbarMessage(ImportMediaSnackbarMessages.MaxAmountOfAssetsReached) - } else { - val jobs: MutableCollection = mutableListOf() - - textToSend?.let { - sendTextMessage( - conversationId = conversation.conversationId, - text = it - ) - } ?: assetsToSend.forEach { importedAsset -> - val isImage = importedAsset is ImportedMediaAsset.Image - val job = viewModelScope.launch { - sendAssetMessage( - conversationId = conversation.conversationId, - assetDataPath = importedAsset.assetBundle.dataPath, - assetName = importedAsset.assetBundle.fileName, - assetDataSize = importedAsset.assetBundle.dataSize, - assetMimeType = importedAsset.assetBundle.mimeType, - assetWidth = if (isImage) (importedAsset as ImportedMediaAsset.Image).width else 0, - assetHeight = if (isImage) (importedAsset as ImportedMediaAsset.Image).height else 0, - audioLengthInMs = getAudioLengthInMs( - dataPath = importedAsset.assetBundle.dataPath, - mimeType = importedAsset.assetBundle.mimeType, - ) - ).also { - handleError(it, conversation.conversationId) - } - } - jobs.add(job) - } - - jobs.joinAll() - withContext(dispatchers.main()) { - onSent(conversation.conversationId) - } - } - } - private fun handleError(result: ScheduleNewAssetMessageResult, conversationId: ConversationId) { when (result) { is ScheduleNewAssetMessageResult.Success -> appLogger.d( @@ -428,6 +383,5 @@ data class ImportMediaAuthenticatedState( val isImporting: Boolean = false, val shareableConversationListState: ShareableConversationListState = ShareableConversationListState(), val selectedConversationItem: List = emptyList(), - val selfDeletingTimer: SelfDeletionTimer = SelfDeletionTimer.Enabled(null), - val assetSendError: AssetSendError? = null + val selfDeletingTimer: SelfDeletionTimer = SelfDeletionTimer.Enabled(null) ) diff --git a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt index 8d06d1f86c5..0d1b583e7be 100644 --- a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt @@ -121,17 +121,15 @@ fun ImportMediaScreen( ) } - FeatureFlagState.SharingRestrictedState.RESTRICTED_IN_TEAM, - FeatureFlagState.SharingRestrictedState.NONE -> { + FeatureFlagState.FileSharingState.DisabledByTeam, + FeatureFlagState.FileSharingState.AllowAll, + is FeatureFlagState.FileSharingState.AllowSome -> { ImportMediaAuthenticatedContent( navigator = navigator, - isRestrictedInTeam = fileSharingRestrictedState == FeatureFlagState.SharingRestrictedState.RESTRICTED_IN_TEAM, + isRestrictedInTeam = fileSharingRestrictedState == FeatureFlagState.FileSharingState.DisabledByTeam, ) } - null -> { - // state is not calculated yet, need to wait to avoid crash while requesting currentUser where it's absent - } } BackHandler { navigator.finish() } @@ -220,7 +218,7 @@ fun ImportMediaRestrictedContent( content = { internalPadding -> FileSharingRestrictedContent( internalPadding, - FeatureFlagState.SharingRestrictedState.RESTRICTED_IN_TEAM, + FeatureFlagState.FileSharingState.DisabledByTeam, navigateBack ) } diff --git a/app/src/test/kotlin/com/wire/android/ui/home/conversations/composer/MessageComposerViewModelArrangement.kt b/app/src/test/kotlin/com/wire/android/ui/home/conversations/composer/MessageComposerViewModelArrangement.kt index b80f5d48c29..ace2deec313 100644 --- a/app/src/test/kotlin/com/wire/android/ui/home/conversations/composer/MessageComposerViewModelArrangement.kt +++ b/app/src/test/kotlin/com/wire/android/ui/home/conversations/composer/MessageComposerViewModelArrangement.kt @@ -174,29 +174,6 @@ internal class MessageComposerViewModelArrangement { ) } - fun withStoredAsset(dataPath: Path, dataContent: ByteArray) = apply { - fakeKaliumFileSystem.sink(dataPath).buffer().use { - it.write(dataContent) - } - } - - fun withSuccessfulSendTypingEvent() = apply { - coEvery { - sendTypingEvent( - any(), - any() - ) - } returns Unit - } - - fun withObserveSelfDeletingStatus(expectedSelfDeletionTimer: SelfDeletionTimer) = apply { - coEvery { observeConversationSelfDeletionStatus(conversationId, true) } returns flowOf(expectedSelfDeletionTimer) - } - - fun withPersistSelfDeletionStatus() = apply { - coEvery { persistSelfDeletionStatus(any(), any()) } returns Unit - } - fun withSaveDraftMessage() = apply { coEvery { saveMessageDraftUseCase(any()) } returns Unit } diff --git a/app/src/test/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModelArrangement.kt b/app/src/test/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModelArrangement.kt index 5e3c9d2c96c..5f52a44519c 100644 --- a/app/src/test/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModelArrangement.kt +++ b/app/src/test/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModelArrangement.kt @@ -18,6 +18,7 @@ package com.wire.android.ui.home.conversations.sendmessage +import androidx.lifecycle.SavedStateHandle import com.wire.android.config.TestDispatcherProvider import com.wire.android.config.mockUri import com.wire.android.framework.FakeKaliumFileSystem @@ -78,6 +79,9 @@ internal class SendMessageViewModelArrangement { coEvery { observeConversationUnderLegalHoldNotified(any()) } returns flowOf(true) } + @MockK + lateinit var savedStateHandle: SavedStateHandle + @MockK lateinit var sendTextMessage: SendTextMessageUseCase diff --git a/default.json b/default.json index 993d59a8f7e..8c7f2faf3c1 100644 --- a/default.json +++ b/default.json @@ -100,7 +100,7 @@ "enable_blacklist": true, "allow_email_change": true, "enable_guest_room_link": true, - "file_restriction_enabled": false, + "file_restriction_enabled": true, "file_restriction_list": "3gpp, aac, amr, avi, bmp, css, csv, dib, doc, docx, eml, flac, gif, html, ico, jfif, jpeg, jpg, jpg-large, key, m4a, m4v, md, midi, mkv, mov, mp3, mp4, mpeg, mpeg3, mpg, msg, ods, odt, ogg, pdf, pjp, pjpeg, png, pps, ppt, pptx, psd, pst, rtf, sql, svg, tex, tiff, txt, vcf, vid, wav, webm, webp, wmv, xls, xlsx, xml", "force_constant_bitrate_calls": false, "ignore_ssl_certificates": false, From bc0fe4d18e78eef9d68a5b93c57235bdb94584fe Mon Sep 17 00:00:00 2001 From: MohamadJaara Date: Mon, 8 Jul 2024 16:40:16 +0200 Subject: [PATCH 3/5] chore: update kalium --- kalium | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kalium b/kalium index a89ab590d62..90b774292e4 160000 --- a/kalium +++ b/kalium @@ -1 +1 @@ -Subproject commit a89ab590d62a7f0d80ad80dab92014113132e68b +Subproject commit 90b774292e47e1cc44e559956bee132b58f02e8e From 99479bc5beed0338e04c12e827e85caaaca2eec0 Mon Sep 17 00:00:00 2001 From: MohamadJaara Date: Mon, 8 Jul 2024 17:00:45 +0200 Subject: [PATCH 4/5] detekt --- .../home/conversations/sendmessage/SendMessageViewModel.kt | 1 - .../attachments/IsFileSharingEnabledViewModel.kt | 2 +- .../android/ui/sharing/ImportMediaAuthenticatedViewModel.kt | 5 ----- .../kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt | 1 - 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModel.kt index 3ab0e70b356..ebf8afaffb1 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/sendmessage/SendMessageViewModel.kt @@ -42,7 +42,6 @@ import com.wire.android.ui.navArgs import com.wire.android.ui.sharing.SendMessagesSnackbarMessages import com.wire.android.util.SUPPORTED_AUDIO_MIME_TYPE import com.wire.android.util.ImageUtil -import com.wire.android.util.SUPPORTED_AUDIO_MIME_TYPE import com.wire.android.util.dispatchers.DispatcherProvider import com.wire.android.util.getAudioLengthInMs import com.wire.kalium.logic.CoreFailure diff --git a/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/attachments/IsFileSharingEnabledViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/attachments/IsFileSharingEnabledViewModel.kt index c0a2ebbefb0..5c8d8a441fe 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/attachments/IsFileSharingEnabledViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/attachments/IsFileSharingEnabledViewModel.kt @@ -50,7 +50,7 @@ class IsFileSharingEnabledViewModelImpl @Inject constructor( private fun getIsFileSharingEnabled() = viewModelScope.launch { state = when (isFileSharingEnabledUseCase().state) { - FileSharingStatus.Value.Disabled-> false + FileSharingStatus.Value.Disabled -> false FileSharingStatus.Value.EnabledAll, is FileSharingStatus.Value.EnabledSome -> true } diff --git a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt index 946a92673be..6140c874f3b 100644 --- a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt @@ -17,11 +17,9 @@ */ package com.wire.android.ui.sharing -import android.content.Context import android.content.Intent import android.net.Uri import android.os.Parcelable -import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.compose.foundation.text.input.TextFieldState import androidx.compose.runtime.Stable @@ -39,7 +37,6 @@ import com.wire.android.model.ImageAsset import com.wire.android.model.SnackBarMessage import com.wire.android.model.UserAvatarData import com.wire.android.ui.home.conversations.ConversationSnackbarMessages -import com.wire.android.ui.home.conversations.model.AssetBundle import com.wire.android.ui.common.textfield.textAsFlow import com.wire.android.ui.home.conversations.search.DEFAULT_SEARCH_QUERY_DEBOUNCE import com.wire.android.ui.home.conversations.usecase.HandleUriAssetUseCase @@ -64,7 +61,6 @@ import com.wire.kalium.logic.feature.selfDeletingMessages.ObserveSelfDeletionTim import com.wire.kalium.logic.feature.selfDeletingMessages.PersistNewSelfDeletionTimerUseCase import com.wire.kalium.logic.feature.user.GetSelfUserUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toPersistentList @@ -87,7 +83,6 @@ import javax.inject.Inject @OptIn(FlowPreview::class) @Suppress("LongParameterList", "TooManyFunctions") class ImportMediaAuthenticatedViewModel @Inject constructor( - @ApplicationContext private val context: Context, private val getSelf: GetSelfUserUseCase, private val userTypeMapper: UserTypeMapper, private val observeConversationListDetails: ObserveConversationListDetailsUseCase, diff --git a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt index 0d1b583e7be..56b124aa018 100644 --- a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt @@ -129,7 +129,6 @@ fun ImportMediaScreen( isRestrictedInTeam = fileSharingRestrictedState == FeatureFlagState.FileSharingState.DisabledByTeam, ) } - } BackHandler { navigator.finish() } From d830e38c8d53027d11c82c19fb6c60893c32e095 Mon Sep 17 00:00:00 2001 From: MohamadJaara Date: Mon, 8 Jul 2024 20:41:54 +0200 Subject: [PATCH 5/5] revert changes in default.json --- default.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.json b/default.json index 8c7f2faf3c1..993d59a8f7e 100644 --- a/default.json +++ b/default.json @@ -100,7 +100,7 @@ "enable_blacklist": true, "allow_email_change": true, "enable_guest_room_link": true, - "file_restriction_enabled": true, + "file_restriction_enabled": false, "file_restriction_list": "3gpp, aac, amr, avi, bmp, css, csv, dib, doc, docx, eml, flac, gif, html, ico, jfif, jpeg, jpg, jpg-large, key, m4a, m4v, md, midi, mkv, mov, mp3, mp4, mpeg, mpeg3, mpg, msg, ods, odt, ogg, pdf, pjp, pjpeg, png, pps, ppt, pptx, psd, pst, rtf, sql, svg, tex, tiff, txt, vcf, vid, wav, webm, webp, wmv, xls, xlsx, xml", "force_constant_bitrate_calls": false, "ignore_ssl_certificates": false,