More protobufjs migration
This commit is contained in:
parent
cf06e6638e
commit
ddbbe3a6b1
70 changed files with 3967 additions and 3369 deletions
60
ts/textsecure/processSyncMessage.ts
Normal file
60
ts/textsecure/processSyncMessage.ts
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { SignalService as Proto } from '../protobuf';
|
||||
import { normalizeUuid } from '../util/normalizeUuid';
|
||||
import {
|
||||
ProcessedUnidentifiedDeliveryStatus,
|
||||
ProcessedSent,
|
||||
ProcessedSyncMessage,
|
||||
} from './Types.d';
|
||||
|
||||
import UnidentifiedDeliveryStatus = Proto.SyncMessage.Sent.IUnidentifiedDeliveryStatus;
|
||||
|
||||
function processUnidentifiedDeliveryStatus(
|
||||
status: UnidentifiedDeliveryStatus
|
||||
): ProcessedUnidentifiedDeliveryStatus {
|
||||
const { destinationUuid } = status;
|
||||
|
||||
return {
|
||||
...status,
|
||||
|
||||
destinationUuid: destinationUuid
|
||||
? normalizeUuid(
|
||||
destinationUuid,
|
||||
'syncMessage.sent.unidentifiedStatus.destinationUuid'
|
||||
)
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
function processSent(
|
||||
sent?: Proto.SyncMessage.ISent | null
|
||||
): ProcessedSent | undefined {
|
||||
if (!sent) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const { destinationUuid, unidentifiedStatus } = sent;
|
||||
|
||||
return {
|
||||
...sent,
|
||||
|
||||
destinationUuid: destinationUuid
|
||||
? normalizeUuid(destinationUuid, 'syncMessage.sent.destinationUuid')
|
||||
: undefined,
|
||||
|
||||
unidentifiedStatus: unidentifiedStatus
|
||||
? unidentifiedStatus.map(processUnidentifiedDeliveryStatus)
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function processSyncMessage(
|
||||
syncMessage: Proto.ISyncMessage
|
||||
): ProcessedSyncMessage {
|
||||
return {
|
||||
...syncMessage,
|
||||
sent: processSent(syncMessage.sent),
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue