Use uuidv7 in callDisposition

This commit is contained in:
Fedor Indutny 2024-10-16 13:03:45 -07:00 committed by GitHub
parent ab87c815c9
commit 32f9f489c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,13 +11,13 @@ import {
callIdFromRingId, callIdFromRingId,
RingUpdate, RingUpdate,
} from '@signalapp/ringrtc'; } from '@signalapp/ringrtc';
import { v4 as generateGuid } from 'uuid';
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import { strictAssert } from './assert'; import { strictAssert } from './assert';
import { DataReader, DataWriter } from '../sql/Client'; import { DataReader, DataWriter } from '../sql/Client';
import { SignalService as Proto } from '../protobuf'; import { SignalService as Proto } from '../protobuf';
import { bytesToUuid, uuidToBytes } from './uuidToBytes'; import { bytesToUuid, uuidToBytes } from './uuidToBytes';
import { missingCaseError } from './missingCaseError'; import { missingCaseError } from './missingCaseError';
import { generateMessageId } from './generateMessageId';
import { CallEndedReason, GroupCallJoinState } from '../types/Calling'; import { CallEndedReason, GroupCallJoinState } from '../types/Calling';
import { import {
CallMode, CallMode,
@ -1212,16 +1212,18 @@ async function saveCallHistory({
seenStatus = maxSeenStatus(seenStatus, prevMessage.seenStatus); seenStatus = maxSeenStatus(seenStatus, prevMessage.seenStatus);
} }
const counter =
prevMessage?.received_at ?? receivedAtCounter ?? incrementMessageCounter();
const { id: newId } = generateMessageId(counter);
const message: MessageAttributesType = { const message: MessageAttributesType = {
id: prevMessage?.id ?? generateGuid(), id: prevMessage?.id ?? newId,
conversationId: conversation.id, conversationId: conversation.id,
type: 'call-history', type: 'call-history',
timestamp: prevMessage?.timestamp ?? callHistory.timestamp, timestamp: prevMessage?.timestamp ?? callHistory.timestamp,
sent_at: prevMessage?.sent_at ?? callHistory.timestamp, sent_at: prevMessage?.sent_at ?? callHistory.timestamp,
received_at: received_at: counter,
prevMessage?.received_at ??
receivedAtCounter ??
incrementMessageCounter(),
received_at_ms: received_at_ms:
prevMessage?.received_at_ms ?? receivedAtMS ?? callHistory.timestamp, prevMessage?.received_at_ms ?? receivedAtMS ?? callHistory.timestamp,
readStatus: ReadStatus.Read, readStatus: ReadStatus.Read,