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

@ -111,16 +111,16 @@ export function getPaymentEventDescription(
export function isQuoteAMatch(
message: MessageAttributesType | null | undefined,
conversationId: string,
quote: Pick<QuotedMessageType, 'id' | 'authorUuid' | 'author'>
quote: Pick<QuotedMessageType, 'id' | 'authorAci' | 'author'>
): message is MessageAttributesType {
if (!message) {
return false;
}
const { authorUuid, id } = quote;
const { authorAci, id } = quote;
const authorConversation = window.ConversationController.lookupOrCreate({
e164: 'author' in quote ? quote.author : undefined,
uuid: authorUuid,
serviceId: authorAci,
reason: 'helpers.isQuoteAMatch',
});
@ -137,18 +137,18 @@ export function isQuoteAMatch(
}
export function getContactId(
message: Pick<MessageAttributesType, 'type' | 'source' | 'sourceUuid'>
message: Pick<MessageAttributesType, 'type' | 'source' | 'sourceServiceId'>
): string | undefined {
const source = getSource(message);
const sourceUuid = getSourceUuid(message);
const sourceServiceId = getSourceServiceId(message);
if (!source && !sourceUuid) {
if (!source && !sourceServiceId) {
return window.ConversationController.getOurConversationId();
}
const conversation = window.ConversationController.lookupOrCreate({
e164: source,
uuid: sourceUuid,
serviceId: sourceServiceId,
reason: 'helpers.getContactId',
});
return conversation?.id;
@ -191,15 +191,15 @@ export function getSourceDevice(
return sourceDevice || window.textsecure.storage.user.getDeviceId();
}
export function getSourceUuid(
message: Pick<MessageAttributesType, 'type' | 'sourceUuid'>
export function getSourceServiceId(
message: Pick<MessageAttributesType, 'type' | 'sourceServiceId'>
): ServiceIdString | undefined {
if (isIncoming(message) || isStory(message)) {
return message.sourceUuid;
return message.sourceServiceId;
}
if (!isOutgoing(message)) {
log.warn(
'Message.getSourceUuid: Called for non-incoming/non-outgoing message'
'Message.getSourceServiceId: Called for non-incoming/non-outgoing message'
);
}