Introduce Service Id Types

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
Fedor Indutny 2023-08-10 18:43:33 +02:00 committed by Jamie Kyle
parent 414c0a58d3
commit 366b875fd2
269 changed files with 5832 additions and 5550 deletions

View file

@ -13,6 +13,7 @@ import {
UnregisteredUserError,
} from '../textsecure/Errors';
import { SEALED_SENDER } from '../types/SealedSender';
import type { ServiceIdString } from '../types/ServiceId';
const { insertSentProto, updateConversation } = dataInterface;
@ -130,7 +131,7 @@ function processError(error: unknown): void {
}
if (error instanceof UnregisteredUserError) {
const conversation = window.ConversationController.getOrCreate(
error.identifier,
error.serviceId,
'private'
);
log.warn(
@ -153,7 +154,7 @@ export async function handleMessageSend(
await maybeSaveToSendLog(result, options);
await handleMessageSendResult(
result.failoverIdentifiers,
result.failoverServiceIds,
result.unidentifiedDeliveries
);
@ -163,7 +164,7 @@ export async function handleMessageSend(
if (err instanceof SendMessageProtoError) {
await handleMessageSendResult(
err.failoverIdentifiers,
err.failoverServiceIds,
err.unidentifiedDeliveries
);
@ -175,12 +176,12 @@ export async function handleMessageSend(
}
async function handleMessageSendResult(
failoverIdentifiers: Array<string> | undefined,
unidentifiedDeliveries: Array<string> | undefined
failoverServiceIds: Array<ServiceIdString> | undefined,
unidentifiedDeliveries: Array<ServiceIdString> | undefined
): Promise<void> {
await Promise.all(
(failoverIdentifiers || []).map(async identifier => {
const conversation = window.ConversationController.get(identifier);
(failoverServiceIds || []).map(async serviceId => {
const conversation = window.ConversationController.get(serviceId);
if (
conversation &&
@ -198,8 +199,8 @@ async function handleMessageSendResult(
);
await Promise.all(
(unidentifiedDeliveries || []).map(async identifier => {
const conversation = window.ConversationController.get(identifier);
(unidentifiedDeliveries || []).map(async serviceId => {
const conversation = window.ConversationController.get(serviceId);
if (
conversation &&