Skip to content

Commit

Permalink
feat: location messages backup (WPB-5826) (#2324)
Browse files Browse the repository at this point in the history
* feat: location backup

* feat: location backup, delete ephemeral

* feat: location backup
  • Loading branch information
yamilmedina authored Dec 21, 2023
1 parent 8c0b71d commit e07f991
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,24 @@ INSERT INTO Receipt
OR selfdelete_message_id.conversation_id IS NULL;

INSERT INTO ButtonContent SELECT * FROM local_db.ButtonContent;

WITH selfdelete_message_id AS (
SELECT local_db.Message.id, local_db.Message.conversation_id
FROM local_db.Message
WHERE local_db.Message.expire_after_millis IS NOT NULL
)
INSERT INTO MessageConversationLocationContent
SELECT local_db.MessageConversationLocationContent.message_id,
local_db.MessageConversationLocationContent.conversation_id,
local_db.MessageConversationLocationContent.latitude,
local_db.MessageConversationLocationContent.longitude,
local_db.MessageConversationLocationContent.name,
local_db.MessageConversationLocationContent.zoom
FROM local_db.MessageConversationLocationContent
LEFT JOIN selfdelete_message_id
ON local_db.MessageConversationLocationContent.message_id = selfdelete_message_id.id
AND local_db.MessageConversationLocationContent.conversation_id = selfdelete_message_id.conversation_id
WHERE selfdelete_message_id.id IS NULL
OR selfdelete_message_id.conversation_id IS NULL;

}
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@ INSERT OR IGNORE INTO Receipt SELECT * FROM backup_db.Receipt;

importCompositeButtons:
INSERT OR IGNORE INTO ButtonContent SELECT * FROM backup_db.ButtonContent;

importMessageLocationContentTable:
INSERT OR IGNORE INTO MessageConversationLocationContent SELECT * FROM backup_db.MessageConversationLocationContent;
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ markMessageAsDeleted {
DELETE FROM MessageMemberChangeContent WHERE message_id = :message_id AND conversation_id = :conversation_id;
DELETE FROM MessageUnknownContent WHERE message_id = :message_id AND conversation_id = :conversation_id;
DELETE FROM MessageRestrictedAssetContent WHERE message_id = :message_id AND conversation_id = :conversation_id;
DELETE FROM MessageConversationLocationContent WHERE message_id = :message_id AND conversation_id = :conversation_id;
-- deleted messages will not have a quote 100%
-- TODO: why inserting a NULL here? Shouldn't we just not insert anything?
INSERT INTO MessageTextContent(message_id, conversation_id, text_body, is_quoting_self) VALUES(:message_id, :conversation_id, NULL, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ internal class DatabaseImporterImpl internal constructor(
importReactionTable()
importReceiptTable()
importCompositeButtons()
importMessageLocationContentTable()
}
}
}
Expand Down

0 comments on commit e07f991

Please sign in to comment.