Skip to content

Commit

Permalink
feat: Inform user about degraded conversation verification status: re…
Browse files Browse the repository at this point in the history
…view fixes
  • Loading branch information
borichellow committed Jul 19, 2023
1 parent 751c808 commit 67a3af3
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ sealed interface Message {
typeKey to "mlsWrongEpochWarning"
)

is MessageContent.VerificationDegraded -> mutableMapOf(
typeKey to "verificationDegraded"
is MessageContent.ConversationDegraded -> mutableMapOf(
typeKey to "conversationDegraded"
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ sealed class MessageContent {

object HistoryLost : System()
object ConversationCreated : System()
data class VerificationDegraded(val protocol: Conversation.Protocol?) : System()
data class ConversationDegraded(val protocol: Conversation.Protocol?) : System()
}

/**
Expand Down Expand Up @@ -281,7 +281,7 @@ fun MessageContent?.getType() = when (this) {
is MessageContent.MemberChange.CreationAdded -> "MemberChange.CreationAdded"
is MessageContent.MemberChange.FailedToAdd -> "MemberChange.FailedToAdd"
is MessageContent.MLSWrongEpochWarning -> "MLSWrongEpochWarning"
is MessageContent.VerificationDegraded -> "Verification status degraded"
is MessageContent.ConversationDegraded -> "Verification status degraded"
null -> "Unknown"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class MessageMapperImpl(
MessageEntity.ContentType.CONVERSATION_MESSAGE_TIMER_CHANGED -> null
MessageEntity.ContentType.CONVERSATION_CREATED -> null
MessageEntity.ContentType.MLS_WRONG_EPOCH_WARNING -> null
MessageEntity.ContentType.VERIFICATION_DEGRADED -> null
MessageEntity.ContentType.CONVERSATION_DEGRADED -> null
}
}

Expand Down Expand Up @@ -360,7 +360,7 @@ class MessageMapperImpl(
is MessageContent.ConversationMessageTimerChanged -> MessageEntityContent.ConversationMessageTimerChanged(messageTimer)
is MessageContent.ConversationCreated -> MessageEntityContent.ConversationCreated
is MessageContent.MLSWrongEpochWarning -> MessageEntityContent.MLSWrongEpochWarning
is MessageContent.VerificationDegraded -> MessageEntityContent.VerificationDegraded(conversationMapper.toDaoModel(protocol))
is MessageContent.ConversationDegraded -> MessageEntityContent.ConversationDegraded(conversationMapper.toDaoModel(protocol))
}

private fun MessageEntityContent.Regular.toMessageContent(hidden: Boolean): MessageContent.Regular = when (this) {
Expand Down Expand Up @@ -448,7 +448,7 @@ class MessageMapperImpl(
is MessageEntityContent.ConversationMessageTimerChanged -> MessageContent.ConversationMessageTimerChanged(messageTimer)
is MessageEntityContent.ConversationCreated -> MessageContent.ConversationCreated
is MessageEntityContent.MLSWrongEpochWarning -> MessageContent.MLSWrongEpochWarning
is MessageEntityContent.VerificationDegraded -> MessageContent.VerificationDegraded(conversationMapper.fromDaoModel(protocol))
is MessageEntityContent.ConversationDegraded -> MessageContent.ConversationDegraded(conversationMapper.fromDaoModel(protocol))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ internal class PersistMessageUseCaseImpl(
is MessageContent.MemberChange.FailedToAdd -> false
is MessageContent.ConversationCreated -> false
is MessageContent.MLSWrongEpochWarning -> false
is MessageContent.VerificationDegraded -> false
is MessageContent.ConversationDegraded -> false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ internal class ConversationVerificationStatusHandlerImpl(

override suspend fun invoke(conversation: Conversation, status: ConversationVerificationStatus): Unit = withContext(dispatcher) {
if (shouldNotifyUser(conversation, status)) {
val verificationDegradedMessage = Message.System(
val conversationDegradedMessage = Message.System(
id = uuid4().toString(),
content = MessageContent.VerificationDegraded(protocolInfoMapper.fromInfoToProtocol(conversation.protocol)),
content = MessageContent.ConversationDegraded(protocolInfoMapper.fromInfoToProtocol(conversation.protocol)),
conversationId = conversation.id,
date = DateTimeUtil.currentIsoDateTimeString(),
senderUserId = selfUserId,
Expand All @@ -63,7 +63,7 @@ internal class ConversationVerificationStatusHandlerImpl(
expirationData = null
)

persistMessage(verificationDegradedMessage)
persistMessage(conversationDegradedMessage)
.flatMap { conversationRepository.setInformedAboutDegradedMLSVerificationFlag(conversation.id, true) }
} else {
conversationRepository.setInformedAboutDegradedMLSVerificationFlag(conversation.id, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CREATE TABLE Conversation (
message_timer INTEGER DEFAULT(NULL),
user_message_timer INTEGER DEFAULT(NULL),
incomplete_metadata INTEGER AS Boolean NOT NULL DEFAULT 0,
informed_about_degraded_mls_verification INTEGER AS Boolean NOT NULL DEFAULT 0
is_mls_degraded_notified INTEGER AS Boolean NOT NULL DEFAULT 0
);

-- Optimise comparisons and sorting by dates:
Expand Down
2 changes: 1 addition & 1 deletion persistence/src/commonMain/db_user/migrations/50.sqm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import com.wire.kalium.persistence.dao.QualifiedIDEntity;
import com.wire.kalium.persistence.dao.message.RecipientFailureTypeEntity;
import kotlin.collections.List;

ALTER TABLE Conversation ADD COLUMN informed_about_degraded_mls_verification INTEGER AS Boolean NOT NULL DEFAULT 0;
ALTER TABLE Conversation ADD COLUMN is_mls_degraded_notified INTEGER AS Boolean NOT NULL DEFAULT 0;

DROP VIEW IF EXISTS MessageDetailsView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ sealed interface MessageEntity {
TEXT, ASSET, KNOCK, MEMBER_CHANGE, MISSED_CALL, RESTRICTED_ASSET,
CONVERSATION_RENAMED, UNKNOWN, FAILED_DECRYPTION, REMOVED_FROM_TEAM, CRYPTO_SESSION_RESET,
NEW_CONVERSATION_RECEIPT_MODE, CONVERSATION_RECEIPT_MODE_CHANGED, HISTORY_LOST, CONVERSATION_MESSAGE_TIMER_CHANGED,
CONVERSATION_CREATED, MLS_WRONG_EPOCH_WARNING, VERIFICATION_DEGRADED
CONVERSATION_CREATED, MLS_WRONG_EPOCH_WARNING, CONVERSATION_DEGRADED
}

enum class MemberChangeType {
Expand Down Expand Up @@ -302,7 +302,7 @@ sealed class MessageEntityContent {
data class ConversationMessageTimerChanged(val messageTimer: Long?) : System()
object HistoryLost : System()
object ConversationCreated : System()
data class VerificationDegraded(val protocol: ConversationEntity.Protocol?) : System()
data class ConversationDegraded(val protocol: ConversationEntity.Protocol?) : System()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ internal class MessageInsertExtensionImpl(
/* no-op */
}

is MessageEntityContent.VerificationDegraded -> {
is MessageEntityContent.ConversationDegraded -> {
/* no-op */
}
}
Expand Down Expand Up @@ -326,6 +326,6 @@ internal class MessageInsertExtensionImpl(
is MessageEntityContent.ConversationMessageTimerChanged -> MessageEntity.ContentType.CONVERSATION_MESSAGE_TIMER_CHANGED
is MessageEntityContent.ConversationCreated -> MessageEntity.ContentType.CONVERSATION_CREATED
is MessageEntityContent.MLSWrongEpochWarning -> MessageEntity.ContentType.MLS_WRONG_EPOCH_WARNING
is MessageEntityContent.VerificationDegraded -> MessageEntity.ContentType.VERIFICATION_DEGRADED
is MessageEntityContent.ConversationDegraded -> MessageEntity.ContentType.CONVERSATION_DEGRADED
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ object MessageMapper {
MessageEntity.ContentType.CONVERSATION_MESSAGE_TIMER_CHANGED -> MessagePreviewEntityContent.Unknown
MessageEntity.ContentType.CONVERSATION_CREATED -> MessagePreviewEntityContent.Unknown
MessageEntity.ContentType.MLS_WRONG_EPOCH_WARNING -> MessagePreviewEntityContent.Unknown
MessageEntity.ContentType.VERIFICATION_DEGRADED -> MessagePreviewEntityContent.Unknown
MessageEntity.ContentType.CONVERSATION_DEGRADED -> MessagePreviewEntityContent.Unknown
}
}

Expand Down Expand Up @@ -507,7 +507,7 @@ object MessageMapper {

MessageEntity.ContentType.CONVERSATION_CREATED -> MessageEntityContent.ConversationCreated
MessageEntity.ContentType.MLS_WRONG_EPOCH_WARNING -> MessageEntityContent.MLSWrongEpochWarning
MessageEntity.ContentType.VERIFICATION_DEGRADED -> MessageEntityContent.VerificationDegraded(conversationProtocol)
MessageEntity.ContentType.CONVERSATION_DEGRADED -> MessageEntityContent.ConversationDegraded(conversationProtocol)
}

return createMessageEntity(
Expand Down

0 comments on commit 67a3af3

Please sign in to comment.