signal-desktop/ts/util/onCallEventSync.ts

41 lines
1.1 KiB
TypeScript
Raw Normal View History

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