diff --git a/VERSION b/VERSION index 088af00f9..8042d7e1e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.122.2 +0.122.3 diff --git a/protocol/common/message.go b/protocol/common/message.go index 553bfa75f..5133bfdad 100644 --- a/protocol/common/message.go +++ b/protocol/common/message.go @@ -37,6 +37,8 @@ type QuotedMessage struct { HasSticker bool `json:"sticker,omitempty"` // CommunityID is the id of the community advertised CommunityID string `json:"communityId,omitempty"` + + Deleted bool `json:"deleted,omitempty"` } type CommandState int diff --git a/protocol/message_persistence.go b/protocol/message_persistence.go index 0b09c190d..b187c0655 100644 --- a/protocol/message_persistence.go +++ b/protocol/message_persistence.go @@ -16,7 +16,7 @@ var basicMessagesSelectQuery = ` SELECT %s %s FROM user_messages m1 LEFT JOIN user_messages m2 -ON m1.response_to = m2.id AND m2.deleted = 0 +ON m1.response_to = m2.id LEFT JOIN contacts c ON m1.source = c.id LEFT JOIN discord_messages dm @@ -170,6 +170,7 @@ func (db sqlitePersistence) tableUserMessagesAllFieldsJoin() string { m2.community_id, m2.id, m2.content_type, + m2.deleted, c.alias, c.identicon` } @@ -190,6 +191,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message var quotedFrom sql.NullString var quotedAudioDuration sql.NullInt64 var quotedCommunityID sql.NullString + var quotedDeleted sql.NullBool var serializedMentions []byte var serializedLinks []byte var alias sql.NullString @@ -289,6 +291,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message "edCommunityID, "edID, &ContentType, + "edDeleted, &alias, &identicon, } @@ -318,13 +321,21 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message } if quotedText.Valid { - message.QuotedMessage = &common.QuotedMessage{ - ID: quotedID.String, - ContentType: ContentType.Int64, - From: quotedFrom.String, - Text: quotedText.String, - ParsedText: quotedParsedText, - CommunityID: quotedCommunityID.String, + if quotedDeleted.Bool == true { + message.QuotedMessage = &common.QuotedMessage{ + ID: quotedID.String, + Deleted: quotedDeleted.Bool, + } + } else { + message.QuotedMessage = &common.QuotedMessage{ + ID: quotedID.String, + ContentType: ContentType.Int64, + From: quotedFrom.String, + Text: quotedText.String, + ParsedText: quotedParsedText, + CommunityID: quotedCommunityID.String, + Deleted: quotedDeleted.Bool, + } } } message.Alias = alias.String diff --git a/protocol/persistence_test.go b/protocol/persistence_test.go index e9a196e2f..835713249 100644 --- a/protocol/persistence_test.go +++ b/protocol/persistence_test.go @@ -555,9 +555,9 @@ func TestMessageReplies(t *testing.T) { require.Equal(t, "", retrievedMessages[4].ResponseTo) require.Nil(t, retrievedMessages[4].QuotedMessage) - // We have a ResponseTo, but no QuotedMessage, since the message was deleted + // We have a ResponseTo, but no QuotedMessage only gives the ID and Deleted require.Equal(t, "id-4", retrievedMessages[0].ResponseTo) - require.Nil(t, retrievedMessages[0].QuotedMessage) + require.Equal(t, &common.QuotedMessage{ID: "id-4", Deleted: true}, retrievedMessages[0].QuotedMessage) } func TestMessageByChatIDWithTheSameClocks(t *testing.T) {