Skip to content

Commit

Permalink
feat: Inform user about degraded conversation verification status (WP…
Browse files Browse the repository at this point in the history
…D-573) (#1989)
  • Loading branch information
borichellow authored and vitorhugods committed Jul 24, 2023
1 parent 9b65baf commit 0cf6486
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.wire.android.ui.home.conversations.selfdeletion.SelfDeletionMapper.to
import com.wire.android.util.formatFullDateShortTime
import com.wire.android.util.orDefault
import com.wire.android.util.ui.UIText
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.message.Message
import com.wire.kalium.logic.data.message.MessageContent
import com.wire.kalium.logic.data.message.MessageContent.MemberChange
Expand Down Expand Up @@ -61,6 +62,8 @@ class SystemMessageContentMapper @Inject constructor(
is MessageContent.ConversationMessageTimerChanged -> mapConversationTimerChanged(message.senderUserId, content, members)
is MessageContent.ConversationCreated -> mapConversationCreated(message.senderUserId, message.date, members)
is MessageContent.MLSWrongEpochWarning -> mapMLSWrongEpochWarning()
is MessageContent.ConversationDegradedMLS -> mapConversationDegraded(Conversation.Protocol.MLS)
is MessageContent.ConversationDegradedProteus -> mapConversationDegraded(Conversation.Protocol.PROTEUS)
}

private fun mapConversationCreated(senderUserId: UserId, date: String, userList: List<User>): UIMessageContent.SystemMessage {
Expand Down Expand Up @@ -235,6 +238,9 @@ class SystemMessageContentMapper @Inject constructor(

private fun mapConversationHistoryLost(): UIMessageContent.SystemMessage = UIMessageContent.SystemMessage.HistoryLost()
private fun mapMLSWrongEpochWarning(): UIMessageContent.SystemMessage = UIMessageContent.SystemMessage.MLSWrongEpochWarning()
private fun mapConversationDegraded(protocol: Conversation.Protocol): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.ConversationDegraded(protocol)

fun mapMemberName(user: User?, type: SelfNameType = SelfNameType.NameOrDeleted): UIText = when (user) {
is OtherUser -> user.name?.let { UIText.DynamicString(it) } ?: UIText.StringResource(messageResourceProvider.memberNameDeleted)
is SelfUser -> when (type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ private fun getColorFilter(message: SystemMessage): ColorFilter? {
return when (message) {
is SystemMessage.MissedCall.OtherCalled -> null
is SystemMessage.MissedCall.YouCalled -> null
is SystemMessage.ConversationDegraded -> null
is SystemMessage.Knock -> ColorFilter.tint(colorsScheme().primary)
is SystemMessage.MemberFailedToAdd -> ColorFilter.tint(colorsScheme().error)
is SystemMessage.MemberAdded,
Expand Down Expand Up @@ -387,6 +388,7 @@ private val SystemMessage.expandable
is SystemMessage.MLSWrongEpochWarning -> false
is SystemMessage.ConversationStartedWithMembers -> this.memberNames.size > EXPANDABLE_THRESHOLD
is SystemMessage.MemberFailedToAdd -> this.usersCount > SINGLE_EXPANDABLE_THRESHOLD
is SystemMessage.ConversationDegraded -> false
}

private fun List<String>.toUserNamesListString(res: Resources): String = when {
Expand Down Expand Up @@ -444,6 +446,7 @@ fun SystemMessage.annotatedString(
is SystemMessage.Knock -> arrayOf(author.asString(res))
is SystemMessage.HistoryLost -> arrayOf()
is SystemMessage.MLSWrongEpochWarning -> arrayOf()
is SystemMessage.ConversationDegraded -> arrayOf()
is SystemMessage.ConversationMessageTimerActivated -> arrayOf(
author.asString(res),
selfDeletionDuration.longLabel.asString(res)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.wire.android.ui.home.messagecomposer.SelfDeletionDuration
import com.wire.android.util.ui.UIText
import com.wire.android.util.uiMessageDateTime
import com.wire.kalium.logic.data.conversation.ClientId
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.message.Message
import com.wire.kalium.logic.data.message.MessageContent
import com.wire.kalium.logic.data.user.AssetId
Expand Down Expand Up @@ -65,8 +66,8 @@ sealed interface UIMessage {
override val isPending: Boolean = header.messageStatus.flowStatus == MessageFlowStatus.Sending
val isMyMessage = source == MessageSource.Self
val isAssetMessage = messageContent is UIMessageContent.AssetMessage
|| messageContent is UIMessageContent.ImageMessage
|| messageContent is UIMessageContent.AudioAssetMessage
|| messageContent is UIMessageContent.ImageMessage
|| messageContent is UIMessageContent.AudioAssetMessage
val isTextContentWithoutQuote = messageContent is UIMessageContent.TextMessage && messageContent.messageBody.quotedMessage == null
}

Expand Down Expand Up @@ -402,6 +403,12 @@ sealed class UIMessageContent {
) {
val usersCount = memberNames.values.flatten().size
}

data class ConversationDegraded(val protocol: Conversation.Protocol) : SystemMessage(
if (protocol == Conversation.Protocol.MLS) R.drawable.ic_conversation_degraded_mls
else R.drawable.ic_conversation_degraded_proteus,
R.string.label_system_message_conversation_degraded
)
}
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_conversation_degraded_mls.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:fillColor="#C20013"
android:fillType="evenOdd"
android:pathData="M8,16C12.418,16 16,12.418 16,8C16,3.582 12.418,0 8,0C3.582,0 0,3.582 0,8C0,12.418 3.582,16 8,16ZM8,14C11.314,14 14,11.314 14,8C14,4.686 11.314,2 8,2C4.686,2 2,4.686 2,8C2,11.314 4.686,14 8,14ZM7,8C7,7.448 7.448,7 8,7C8.552,7 9,7.448 9,8V11C9,11.552 8.552,12 8,12C7.448,12 7,11.552 7,11V8ZM8,6C8.552,6 9,5.552 9,5C9,4.448 8.552,4 8,4C7.448,4 7,4.448 7,5C7,5.552 7.448,6 8,6Z" />
</vector>
30 changes: 30 additions & 0 deletions app/src/main/res/drawable/ic_conversation_degraded_proteus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
~ Wire
~ Copyright (C) 2023 Wire Swiss GmbH
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see http://www.gnu.org/licenses/.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:fillColor="#6AA4DE"
android:pathData="M15,1.872V8C15,12 12.034,15.098 8,16 V2L8,0L15,1.872Z" />
<path
android:pathData="M8,16C4.007,15.098 1,12 1,8V2L8,0C8,0 8,13 8,16Z"
android:strokeWidth="1"
android:strokeColor="#6AA4DE" />
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@
<string name="label_system_message_conversation_started_with_members">With %1$s</string>
<string name="label_system_message_conversation_failed_add_members_summary">%1$s **participants** could not be added to the group.</string>
<string name="label_system_message_conversation_failed_add_members_details">%1$s could not be added to the group as the backend of %2$s could not be reached.</string>
<string name="label_system_message_conversation_degraded">This conversation is no longer verified, as some user uses at least one device without a valid end-to-end identity certificate.</string>
<!-- Last messages -->
<plurals name="last_message_self_added_users">
<item quantity="one">You added 1 person to the conversation</item>
Expand Down
2 changes: 1 addition & 1 deletion kalium
Submodule kalium updated 24 files
+2 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/Conversation.kt
+14 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationMapper.kt
+20 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ConversationRepository.kt
+7 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/ProtocolInfoMapper.kt
+8 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/Message.kt
+4 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt
+6 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageMapper.kt
+2 βˆ’0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/PersistMessageUseCase.kt
+13 βˆ’2 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt
+85 βˆ’0 ...c/src/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/ConversationVerificationStatusHandler.kt
+11 βˆ’3 ...rc/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/GetConversationVerificationStatusUseCase.kt
+6 βˆ’1 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/conversation/ConversationRepositoryTest.kt
+220 βˆ’0 ...c/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/ConversationVerificationStatusHandlerTest.kt
+29 βˆ’1 ...ommonTest/kotlin/com/wire/kalium/logic/feature/conversation/GetConversationVerificationStatusUseCaseTest.kt
+11 βˆ’1 persistence/src/commonMain/db_user/com/wire/kalium/persistence/Conversations.sq
+1 βˆ’0 persistence/src/commonMain/db_user/migrations/50.sqm
+1 βˆ’0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/conversation/ConversationDAOImpl.kt
+25 βˆ’0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/conversation/ConversationMetaDataDAO.kt
+37 βˆ’0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/conversation/ConversationMetaDataDAOImpl.kt
+3 βˆ’1 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageEntity.kt
+10 βˆ’0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageInsertExtension.kt
+4 βˆ’0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageMapper.kt
+8 βˆ’0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/db/UserDatabaseBuilder.kt
+89 βˆ’0 persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/ConversationMetaDataDAOTest.kt

0 comments on commit 0cf6486

Please sign in to comment.