Merge contacts when we discover split or duplicated contacts
This commit is contained in:
parent
68e432188b
commit
901179440f
32 changed files with 1199 additions and 824 deletions
|
@ -131,6 +131,7 @@ const dataInterface: ServerInterface = {
|
|||
getOlderMessagesByConversation,
|
||||
getNewerMessagesByConversation,
|
||||
getMessageMetricsForConversation,
|
||||
migrateConversationMessages,
|
||||
|
||||
getUnprocessedCount,
|
||||
getAllUnprocessed,
|
||||
|
@ -2797,6 +2798,25 @@ async function getMessageMetricsForConversation(conversationId: string) {
|
|||
}
|
||||
getMessageMetricsForConversation.needsSerial = true;
|
||||
|
||||
async function migrateConversationMessages(
|
||||
obsoleteId: string,
|
||||
currentId: string
|
||||
) {
|
||||
const db = getInstance();
|
||||
|
||||
await db.run(
|
||||
`UPDATE messages SET
|
||||
conversationId = $currentId,
|
||||
json = json_set(json, '$.conversationId', $currentId)
|
||||
WHERE conversationId = $obsoleteId;`,
|
||||
{
|
||||
$obsoleteId: obsoleteId,
|
||||
$currentId: currentId,
|
||||
}
|
||||
);
|
||||
}
|
||||
migrateConversationMessages.needsSerial = true;
|
||||
|
||||
async function getMessagesBySentAt(sentAt: number) {
|
||||
const db = getInstance();
|
||||
const rows = await db.all(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue