Update CallLogEvent to latest spec

This commit is contained in:
Jamie Kyle 2024-06-25 17:58:38 -07:00 committed by GitHub
parent 815fd77849
commit fc08e70c0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 366 additions and 142 deletions

View file

@ -152,9 +152,11 @@ import { chunk } from '../util/iterables';
import { inspectUnknownFieldTags } from '../util/inspectProtobufs';
import { incrementMessageCounter } from '../util/incrementMessageCounter';
import { filterAndClean } from '../types/BodyRange';
import { getCallEventForProto } from '../util/callDisposition';
import {
getCallEventForProto,
getCallLogEventForProto,
} from '../util/callDisposition';
import { checkOurPniIdentityKey } from '../util/checkOurPniIdentityKey';
import { CallLogEvent } from '../types/CallDisposition';
import { CallLinkUpdateSyncType } from '../types/CallLink';
import { bytesToUuid } from '../util/uuidToBytes';
@ -3614,32 +3616,10 @@ export default class MessageReceiver
const { receivedAtCounter } = envelope;
let event: CallLogEvent;
if (callLogEvent.type == null) {
throw new Error('MessageReceiver.handleCallLogEvent: type was null');
} else if (
callLogEvent.type === Proto.SyncMessage.CallLogEvent.Type.CLEAR
) {
event = CallLogEvent.Clear;
} else if (
callLogEvent.type === Proto.SyncMessage.CallLogEvent.Type.MARKED_AS_READ
) {
event = CallLogEvent.MarkedAsRead;
} else {
throw new Error(
`MessageReceiver.handleCallLogEvent: unknown type ${callLogEvent.type}`
);
}
if (callLogEvent.timestamp == null) {
throw new Error('MessageReceiver.handleCallLogEvent: timestamp was null');
}
const timestamp = callLogEvent.timestamp.toNumber();
const callLogEventDetails = getCallLogEventForProto(callLogEvent);
const callLogEventSync = new CallLogEventSyncEvent(
{
event,
timestamp,
callLogEventDetails,
receivedAtCounter,
},
this.removeFromCache.bind(this, envelope)

View file

@ -89,13 +89,16 @@ import type {
MessageToDelete,
} from './messageReceiverEvents';
import { getConversationFromTarget } from '../util/deleteForMe';
import type { CallDetails } from '../types/CallDisposition';
import type { CallDetails, CallHistoryDetails } from '../types/CallDisposition';
import {
AdhocCallStatus,
DirectCallStatus,
GroupCallStatus,
} from '../types/CallDisposition';
import { getProtoForCallHistory } from '../util/callDisposition';
import {
getBytesForPeerId,
getProtoForCallHistory,
} from '../util/callDisposition';
import { CallMode } from '../types/Calling';
import { MAX_MESSAGE_COUNT } from '../util/deleteForMe.types';
@ -1589,11 +1592,15 @@ export default class MessageSender {
};
}
static getClearCallHistoryMessage(timestamp: number): SingleProtoJobData {
static getClearCallHistoryMessage(
latestCall: CallHistoryDetails
): SingleProtoJobData {
const ourAci = window.textsecure.storage.user.getCheckedAci();
const callLogEvent = new Proto.SyncMessage.CallLogEvent({
type: Proto.SyncMessage.CallLogEvent.Type.CLEAR,
timestamp: Long.fromNumber(timestamp),
timestamp: Long.fromNumber(latestCall.timestamp),
peerId: getBytesForPeerId(latestCall),
callId: Long.fromString(latestCall.callId),
});
const syncMessage = MessageSender.createSyncMessage();

View file

@ -18,7 +18,10 @@ import type {
ProcessedSent,
} from './Types.d';
import type { ContactDetailsWithAvatar } from './ContactsParser';
import type { CallEventDetails, CallLogEvent } from '../types/CallDisposition';
import type {
CallEventDetails,
CallLogEventDetails,
} from '../types/CallDisposition';
import type { CallLinkUpdateSyncType } from '../types/CallLink';
import { isAciString } from '../util/isAciString';
@ -559,14 +562,13 @@ export class DeleteForMeSyncEvent extends ConfirmableEvent {
}
export type CallLogEventSyncEventData = Readonly<{
event: CallLogEvent;
timestamp: number;
callLogEventDetails: CallLogEventDetails;
receivedAtCounter: number;
}>;
export class CallLogEventSyncEvent extends ConfirmableEvent {
constructor(
public readonly callLogEvent: CallLogEventSyncEventData,
public readonly data: CallLogEventSyncEventData,
confirm: ConfirmCallback
) {
super('callLogEventSync', confirm);