-
Notifications
You must be signed in to change notification settings - Fork 46
feat: Restrict access to upload for Viewers profile (WPB-25257) #4849
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
base: develop
Are you sure you want to change the base?
Changes from all commits
938f1d5
247ed5b
63ba58a
63d0739
34d3829
17d356e
abaea77
9821979
f11cbc9
d7d788a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,14 +25,14 @@ import androidx.compose.runtime.setValue | |
| import androidx.lifecycle.SavedStateHandle | ||
| import androidx.lifecycle.ViewModel | ||
| import androidx.lifecycle.viewModelScope | ||
| import com.ramcosta.composedestinations.generated.app.navArgs | ||
| import com.wire.android.datastore.GlobalDataStore | ||
| import com.wire.android.mapper.ContactMapper | ||
| import com.wire.android.ui.home.conversations.ConversationNavArgs | ||
| import com.wire.android.ui.home.conversations.InvalidLinkDialogState | ||
| import com.wire.android.ui.home.conversations.MessageComposerViewState | ||
| import com.wire.android.ui.home.conversations.VisitLinkDialogState | ||
| import com.wire.android.ui.home.conversations.model.UIMessage | ||
| import com.ramcosta.composedestinations.generated.app.navArgs | ||
| import com.wire.android.util.EMPTY | ||
| import com.wire.android.util.FileManager | ||
| import com.wire.android.util.dispatchers.DispatcherProvider | ||
|
|
@@ -45,9 +45,10 @@ import com.wire.kalium.logic.data.message.SelfDeletionTimer | |
| import com.wire.kalium.logic.data.user.OtherUser | ||
| import com.wire.kalium.logic.feature.call.usecase.ObserveEstablishedCallsUseCase | ||
| import com.wire.kalium.logic.feature.conversation.IsInteractionAvailableResult | ||
| import com.wire.kalium.logic.feature.conversation.MarkConversationAsReadLocallyUseCase | ||
| import com.wire.kalium.logic.feature.conversation.MembersToMentionUseCase | ||
| import com.wire.kalium.logic.feature.conversation.ObserveSelfUserHasViewerAccessOnConversationUseCase | ||
| import com.wire.kalium.logic.feature.conversation.ObserveConversationInteractionAvailabilityUseCase | ||
| import com.wire.kalium.logic.feature.conversation.MarkConversationAsReadLocallyUseCase | ||
| import com.wire.kalium.logic.feature.conversation.SendTypingEventUseCase | ||
| import com.wire.kalium.logic.feature.conversation.UpdateConversationReadDateUseCase | ||
| import com.wire.kalium.logic.feature.message.ephemeral.EnqueueMessageSelfDeletionUseCase | ||
|
|
@@ -84,6 +85,7 @@ class MessageComposerViewModel( | |
| private val currentSessionFlowUseCase: CurrentSessionFlowUseCase, | ||
| private val observeEstablishedCalls: ObserveEstablishedCallsUseCase, | ||
| private val globalDataStore: GlobalDataStore, | ||
| private val observeSelfUserHasViewerAccess: ObserveSelfUserHasViewerAccessOnConversationUseCase, | ||
| ) : ViewModel() { | ||
|
|
||
| var messageComposerViewState = mutableStateOf(MessageComposerViewState()) | ||
|
|
@@ -113,6 +115,7 @@ class MessageComposerViewModel( | |
| initTempWritableImageUri() | ||
| observeIsTypingAvailable() | ||
| setFileSharingStatus() | ||
| observeAttachmentOptionsAvailability() | ||
| getEnterToSendState() | ||
| observeCallState() | ||
| } | ||
|
|
@@ -196,6 +199,18 @@ class MessageComposerViewModel( | |
| } | ||
| } | ||
|
|
||
| private fun observeAttachmentOptionsAvailability() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we disable attachment options, should we also disable sharing files into this conversation from other apps?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it will be next, we will restrict download, copy, move, screenshoots... step by step
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it will be better to to add a real restriction on the logic level to make sure we do not depend on the enabled/disabled button states.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This real restriction backend must enforce it |
||
| viewModelScope.launch { | ||
| observeSelfUserHasViewerAccess(conversationId) | ||
| .collectLatest { areAttachmentOptionsEnabled -> | ||
| messageComposerViewState.value = messageComposerViewState.value.copy( | ||
| areAttachmentOptionsEnabled = areAttachmentOptionsEnabled | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| fun updateConversationReadDate(utcISO: String) { | ||
| val instant = Instant.parse(utcISO) | ||
| lastReadInstant = instant | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -388,8 +388,13 @@ fun EnabledMessageComposer( | |
| additionalOptionStateHolder.toRichTextEditing() | ||
| }, | ||
| onCloseRichEditingButtonClicked = additionalOptionStateHolder::toAttachmentAndAdditionalOptionsMenu, | ||
| onDrawingModeClicked = openDrawingCanvas, | ||
| isFileSharingEnabled = messageComposerViewState.value.isFileSharingEnabled | ||
| onDrawingModeClicked = { | ||
| if (messageComposerViewState.value.areAttachmentOptionsEnabled) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for an extra condition here since the button will be disabled when areAttachmentOptionsEnabled == false |
||
| openDrawingCanvas() | ||
| } | ||
| }, | ||
| isFileSharingEnabled = messageComposerViewState.value.isFileSharingEnabled, | ||
| areAttachmentOptionsEnabled = messageComposerViewState.value.areAttachmentOptionsEnabled, | ||
| ) | ||
| } | ||
| } | ||
|
|
@@ -453,6 +458,7 @@ fun EnabledMessageComposer( | |
| AdditionalOptionSubMenu( | ||
| optionsVisible = inputStateHolder.optionsVisible, | ||
| isFileSharingEnabled = messageComposerViewState.value.isFileSharingEnabled, | ||
| areAttachmentOptionsEnabled = messageComposerViewState.value.areAttachmentOptionsEnabled, | ||
| additionalOptionsState = additionalOptionStateHolder.additionalOptionsSubMenuState, | ||
| onRecordAudioMessageClicked = { | ||
| if (!messageComposerViewState.value.isCallOngoing) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not aware of this "Viewers profile" feature but it seems like this does not allow uploading to user from other team. This is a clear business logic and must be placed into kalium use case.