Skip to content
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

fix: show last deleted message [WPB-1899] #2754

Merged
merged 3 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ sealed interface MessagePreviewContent {

data class MissedCall(override val username: String?) : WithUser

data class Deleted(override val username: String?) : WithUser
}

data class Ephemeral(val isGroupConversation: Boolean) : MessagePreviewContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ private fun MessagePreviewEntityContent.toMessageContent(): MessagePreviewConten
is MessagePreviewEntityContent.ConversationVerificationDegradedMls -> MessagePreviewContent.VerificationChanged.DegradedMls
is MessagePreviewEntityContent.ConversationVerificationDegradedProteus -> MessagePreviewContent.VerificationChanged.DegradedProteus
is MessagePreviewEntityContent.Location -> MessagePreviewContent.WithUser.Location(username = senderName)
is MessagePreviewEntityContent.Deleted -> MessagePreviewContent.WithUser.Deleted(username = senderName)
}

fun AssetTypeEntity.toModel(): AssetType = when (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SELECT * FROM MessagePreview AS message
WHERE id IN (
SELECT id FROM Message
WHERE
Message.visibility = 'VISIBLE' AND
Message.visibility IN ('VISIBLE', 'DELETED') AND
Message.content_type IN ('TEXT', 'ASSET', 'KNOCK', 'MISSED_CALL', 'CONVERSATION_RENAMED', 'MEMBER_CHANGE', 'COMPOSITE', 'CONVERSATION_DEGRADED_MLS', 'CONVERSATION_DEGRADED_PROTEUS', 'CONVERSATION_VERIFIED_MLS', 'CONVERSATION_VERIFIED_PROTEUS', 'LOCATION')
GROUP BY Message.conversation_id
HAVING Message.creation_date = MAX(Message.creation_date)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ data class NotificationMessageEntity(

sealed class MessagePreviewEntityContent {

data class Deleted(val senderName: String?) : MessagePreviewEntityContent()
data class Text(val senderName: String?, val messageBody: String) : MessagePreviewEntityContent()

data class Composite(val senderName: String?, val messageBody: String?) : MessagePreviewEntityContent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ object MessageMapper {
@Suppress("ComplexMethod", "LongMethod")
private fun toMessagePreviewEntityContent(
contentType: MessageEntity.ContentType,
visibility: MessageEntity.Visibility,
senderName: String?,
isSelfMessage: Boolean,
memberChangeList: List<QualifiedIDEntity>?,
Expand All @@ -61,6 +62,7 @@ object MessageMapper {
} else {
mapContentType(
contentType,
visibility,
senderName,
isSelfMessage,
memberChangeList,
Expand All @@ -79,6 +81,7 @@ object MessageMapper {
@Suppress("LongMethod", "ComplexMethod")
private fun mapContentType(
contentType: MessageEntity.ContentType,
visibility: MessageEntity.Visibility,
senderName: String?,
isSelfMessage: Boolean,
memberChangeList: List<QualifiedIDEntity>?,
Expand All @@ -90,6 +93,10 @@ object MessageMapper {
selfUserId: QualifiedIDEntity?,
senderUserId: QualifiedIDEntity?
): MessagePreviewEntityContent {
if (visibility == MessageEntity.Visibility.DELETED) {
return MessagePreviewEntityContent.Deleted(senderName)
}

return when (contentType) {
MessageEntity.ContentType.COMPOSITE -> MessagePreviewEntityContent.Composite(
senderName = senderName,
Expand Down Expand Up @@ -253,6 +260,7 @@ object MessageMapper {
): MessagePreviewEntity {
val content = toMessagePreviewEntityContent(
contentType = contentType,
visibility = visibility,
senderName = senderName,
isSelfMessage = isSelfMessage,
memberChangeList = memberChangeList,
Expand Down
Loading