signal-desktop/ts/util/onCallEventSync.ts

27 lines
805 B
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';
2023-08-09 00:53:06 +00:00
import { updateCallHistoryFromRemoteEvent } from './callDisposition';
2023-01-10 00:52:01 +00:00
export async function onCallEventSync(
syncEvent: CallEventSyncEvent
): Promise<void> {
const { callEvent, confirm } = syncEvent;
2023-08-09 00:53:06 +00:00
const { callEventDetails, receivedAtCounter } = callEvent;
const { peerId } = callEventDetails;
2023-01-10 00:52:01 +00:00
2023-08-09 00:53:06 +00:00
const conversation = window.ConversationController.get(peerId);
2023-01-10 00:52:01 +00:00
if (!conversation) {
2023-08-09 00:53:06 +00:00
log.warn(
`onCallEventSync: No conversation found for conversationId ${peerId}`
);
2023-01-10 00:52:01 +00:00
return;
}
2023-08-09 00:53:06 +00:00
await updateCallHistoryFromRemoteEvent(callEventDetails, receivedAtCounter);
confirm();
2023-01-10 00:52:01 +00:00
}