Migrate schema to service ids

This commit is contained in:
Fedor Indutny 2023-08-16 22:54:39 +02:00 committed by Jamie Kyle
parent 71958f8a01
commit 8b0da36caa
258 changed files with 4795 additions and 2613 deletions

View file

@ -22,6 +22,8 @@ import {
conversationQueueJobEnum,
} from '../jobs/conversationJobQueue';
import { ReceiptType } from '../types/Receipt';
import type { AciString } from '../types/ServiceId';
import { isAciString } from '../types/ServiceId';
export async function markConversationRead(
conversationAttrs: ConversationAttributesType,
@ -78,20 +80,20 @@ export async function markConversationRead(
string,
{
messageId?: string;
senderUuid?: string;
senderAci?: AciString;
senderE164?: string;
timestamp: number;
}
>();
unreadReactions.forEach(reaction => {
const targetKey = `${reaction.targetAuthorUuid}/${reaction.targetTimestamp}`;
const targetKey = `${reaction.targetAuthorAci}/${reaction.targetTimestamp}`;
if (unreadReactionSyncData.has(targetKey)) {
return;
}
unreadReactionSyncData.set(targetKey, {
messageId: reaction.messageId,
senderE164: undefined,
senderUuid: reaction.targetAuthorUuid,
senderAci: reaction.targetAuthorAci,
timestamp: reaction.targetTimestamp,
});
});
@ -109,7 +111,7 @@ export async function markConversationRead(
const {
sent_at: timestamp,
source: senderE164,
sourceUuid: senderUuid,
sourceServiceId: senderAci,
} = messageSyncData;
if (!isNumber(timestamp)) {
@ -121,15 +123,24 @@ export async function markConversationRead(
return undefined;
}
if (!isAciString(senderAci)) {
assertDev(
false,
`${logId}: message sourceServiceId timestamp is not aci` +
`type=${messageSyncData.type}`
);
return undefined;
}
return {
messageId: messageSyncData.id,
conversationId: conversationAttrs.id,
originalReadStatus: messageSyncData.originalReadStatus,
senderE164,
senderUuid,
senderAci,
senderId: window.ConversationController.lookupOrCreate({
e164: senderE164,
uuid: senderUuid,
serviceId: senderAci,
reason: 'markConversationRead',
})?.id,
timestamp,
@ -156,7 +167,7 @@ export async function markConversationRead(
const readSyncs: Array<{
messageId?: string;
senderE164?: string;
senderUuid?: string;
senderAci?: AciString;
senderId?: string;
timestamp: number;
hasErrors?: string;