signal-desktop/ts/util/onCallEventSync.ts

41 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-01-09 16:52:01 -08:00
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { CallEventSyncEvent } from '../textsecure/messageReceiverEvents.js';
import { createLogger } from '../logging/log.js';
2024-04-25 10:09:05 -07:00
import {
peerIdToLog,
updateCallHistoryFromRemoteEvent,
} from './callDisposition.js';
import { CallMode } from '../types/CallDisposition.js';
2023-01-09 16:52:01 -08:00
2025-06-16 11:59:31 -07:00
const log = createLogger('onCallEventSync');
2023-01-09 16:52:01 -08:00
export async function onCallEventSync(
syncEvent: CallEventSyncEvent
): Promise<void> {
const { callEvent, confirm } = syncEvent;
const { callEventDetails, receivedAtCounter, receivedAtMS } = callEvent;
2023-01-09 16:52:01 -08:00
2024-04-25 10:09:05 -07:00
if (
callEventDetails.mode === CallMode.Direct ||
callEventDetails.mode === CallMode.Group
) {
const { peerId } = callEventDetails;
const conversation = window.ConversationController.get(peerId);
2023-01-09 16:52:01 -08:00
2024-04-25 10:09:05 -07:00
if (!conversation) {
const peerIdLog = peerIdToLog(peerId, callEventDetails.mode);
2025-06-16 11:59:31 -07:00
log.warn(`No conversation found for conversationId ${peerIdLog}`);
2024-04-25 10:09:05 -07:00
return;
}
2023-01-09 16:52:01 -08:00
}
await updateCallHistoryFromRemoteEvent(
callEventDetails,
receivedAtCounter,
receivedAtMS
);
2023-08-08 17:53:06 -07:00
confirm();
2023-01-09 16:52:01 -08:00
}