2023-01-09 16:52:01 -08:00
|
|
|
// Copyright 2022 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2025-09-16 17:39:03 -07:00
|
|
|
import type { CallEventSyncEvent } from '../textsecure/messageReceiverEvents.js';
|
|
|
|
import { createLogger } from '../logging/log.js';
|
2024-04-25 10:09:05 -07:00
|
|
|
import {
|
|
|
|
peerIdToLog,
|
|
|
|
updateCallHistoryFromRemoteEvent,
|
2025-09-16 17:39:03 -07:00
|
|
|
} 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;
|
2024-05-28 15:13:09 +10:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-05-28 15:13:09 +10:00
|
|
|
await updateCallHistoryFromRemoteEvent(
|
|
|
|
callEventDetails,
|
|
|
|
receivedAtCounter,
|
|
|
|
receivedAtMS
|
|
|
|
);
|
2023-08-08 17:53:06 -07:00
|
|
|
confirm();
|
2023-01-09 16:52:01 -08:00
|
|
|
}
|