mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-25 10:58:19 +01:00
Use new compact representations in protobufs
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
|
||||
import type { SignalService as Proto } from '../protobuf';
|
||||
import type { ServiceIdString } from '../types/ServiceId';
|
||||
import { normalizeServiceId } from '../types/ServiceId';
|
||||
import { fromServiceIdBinaryOrString } from '../util/ServiceId';
|
||||
import type { ProcessedSent, ProcessedSyncMessage } from './Types.d';
|
||||
|
||||
type ProtoServiceId = Readonly<{
|
||||
destinationServiceId?: string | null;
|
||||
destinationServiceIdBinary?: Uint8Array | null;
|
||||
}>;
|
||||
|
||||
function processProtoWithDestinationServiceId<Input extends ProtoServiceId>(
|
||||
@@ -15,14 +16,20 @@ function processProtoWithDestinationServiceId<Input extends ProtoServiceId>(
|
||||
): Omit<Input, keyof ProtoServiceId> & {
|
||||
destinationServiceId?: ServiceIdString;
|
||||
} {
|
||||
const { destinationServiceId, ...remaining } = input;
|
||||
const {
|
||||
destinationServiceId: rawDestinationServiceId,
|
||||
destinationServiceIdBinary,
|
||||
...remaining
|
||||
} = input;
|
||||
|
||||
return {
|
||||
...remaining,
|
||||
|
||||
destinationServiceId: destinationServiceId
|
||||
? normalizeServiceId(destinationServiceId, 'processSyncMessage')
|
||||
: undefined,
|
||||
destinationServiceId: fromServiceIdBinaryOrString(
|
||||
destinationServiceIdBinary,
|
||||
rawDestinationServiceId,
|
||||
'processSyncMessage'
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,7 +41,8 @@ function processSent(
|
||||
}
|
||||
|
||||
const {
|
||||
destinationServiceId,
|
||||
destinationServiceId: rawDestinationServiceId,
|
||||
destinationServiceIdBinary,
|
||||
unidentifiedStatus,
|
||||
storyMessageRecipients,
|
||||
...remaining
|
||||
@@ -43,9 +51,11 @@ function processSent(
|
||||
return {
|
||||
...remaining,
|
||||
|
||||
destinationServiceId: destinationServiceId
|
||||
? normalizeServiceId(destinationServiceId, 'processSent')
|
||||
: undefined,
|
||||
destinationServiceId: fromServiceIdBinaryOrString(
|
||||
destinationServiceIdBinary,
|
||||
rawDestinationServiceId,
|
||||
'processSent'
|
||||
),
|
||||
unidentifiedStatus: unidentifiedStatus
|
||||
? unidentifiedStatus.map(processProtoWithDestinationServiceId)
|
||||
: undefined,
|
||||
|
||||
Reference in New Issue
Block a user