Use protopiler for protocol buffers

Co-authored-by: Jamie Kyle <jamie@signal.org>
This commit is contained in:
Fedor Indutny
2026-03-10 15:31:29 -07:00
committed by GitHub
parent b0e19f334e
commit c4ee32e9ee
97 changed files with 6197 additions and 6362 deletions

View File

@@ -3,8 +3,9 @@
import type { SignalService as Proto } from '../protobuf/index.std.js';
import type { ServiceIdString } from '../types/ServiceId.std.js';
import { normalizeStoryDistributionId } from '../types/StoryDistributionId.std.js';
import { fromServiceIdBinaryOrString } from '../util/ServiceId.node.js';
import type { ProcessedSent, ProcessedSyncMessage } from './Types.d.ts';
import type { ProcessedSent } from './Types.d.ts';
type ProtoServiceId = Readonly<{
destinationServiceId?: string | null;
@@ -33,21 +34,18 @@ function processProtoWithDestinationServiceId<Input extends ProtoServiceId>(
};
}
function processSent(
sent?: Proto.SyncMessage.ISent | null
): ProcessedSent | undefined {
if (!sent) {
return undefined;
}
export function processSent(sent: Proto.SyncMessage.Sent): ProcessedSent {
const {
destinationServiceId: rawDestinationServiceId,
destinationServiceIdBinary,
unidentifiedStatus,
storyMessageRecipients,
$unknown,
...remaining
} = sent;
void $unknown;
return {
...remaining,
@@ -57,19 +55,31 @@ function processSent(
'processSent'
),
unidentifiedStatus: unidentifiedStatus
? unidentifiedStatus.map(processProtoWithDestinationServiceId)
? unidentifiedStatus
.map(processProtoWithDestinationServiceId)
.map(({ unidentified, destinationPniIdentityKey, ...rest }) => {
return {
...rest,
unidentified: unidentified ?? false,
destinationPniIdentityKey: destinationPniIdentityKey ?? undefined,
};
})
: undefined,
storyMessageRecipients: storyMessageRecipients
? storyMessageRecipients.map(processProtoWithDestinationServiceId)
? storyMessageRecipients
.map(processProtoWithDestinationServiceId)
.map(recipient => {
return {
isAllowedToReply: recipient.isAllowedToReply ?? false,
destinationServiceId: recipient.destinationServiceId,
distributionListIds: recipient.distributionListIds.map(id => {
return normalizeStoryDistributionId(
id,
'processSent.storyMessageRecipients'
);
}),
};
})
: undefined,
};
}
export function processSyncMessage(
syncMessage: Proto.ISyncMessage
): ProcessedSyncMessage {
return {
...syncMessage,
sent: processSent(syncMessage.sent),
};
}