Update CallLogEvent to latest spec
This commit is contained in:
parent
815fd77849
commit
fc08e70c0f
12 changed files with 366 additions and 142 deletions
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue