mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-19 07:58:46 +01:00
Use protopiler for protocol buffers
Co-authored-by: Jamie Kyle <jamie@signal.org>
This commit is contained in:
@@ -126,10 +126,15 @@ export type AttachmentForUIType = AttachmentType & {
|
||||
};
|
||||
};
|
||||
|
||||
export type UploadedAttachmentType = Proto.IAttachmentPointer &
|
||||
export type UploadedAttachmentType = Omit<
|
||||
Proto.AttachmentPointer.Params,
|
||||
'attachmentIdentifier'
|
||||
> &
|
||||
Readonly<{
|
||||
// Required fields
|
||||
cdnKey: string;
|
||||
attachmentIdentifier: Readonly<{
|
||||
cdnKey: string;
|
||||
}>;
|
||||
key: Uint8Array;
|
||||
size: number;
|
||||
digest: Uint8Array;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { z } from 'zod';
|
||||
import Long from 'long';
|
||||
import type { AciString } from './ServiceId.std.js';
|
||||
import { aciSchema } from './ServiceId.std.js';
|
||||
import { bytesToUuid } from '../util/uuidToBytes.std.js';
|
||||
@@ -10,6 +9,8 @@ import { SignalService as Proto } from '../protobuf/index.std.js';
|
||||
import * as Bytes from '../Bytes.std.js';
|
||||
import { UUID_BYTE_SIZE } from './Crypto.std.js';
|
||||
|
||||
import { toNumber } from '../util/toNumber.std.js';
|
||||
|
||||
// These are strings (1) for the backup (2) for Storybook.
|
||||
export enum CallMode {
|
||||
Direct = 'Direct',
|
||||
@@ -272,13 +273,9 @@ const roomIdInBytesSchema = z
|
||||
.instanceof(Uint8Array)
|
||||
.transform(value => Bytes.toHex(value));
|
||||
|
||||
const longToStringSchema = z
|
||||
.instanceof(Long)
|
||||
.transform(long => long.toString());
|
||||
const longToStringSchema = z.bigint().transform(big => big.toString());
|
||||
|
||||
const longToNumberSchema = z
|
||||
.instanceof(Long)
|
||||
.transform(long => long.toNumber());
|
||||
const longToNumberSchema = z.bigint().transform(big => toNumber(big));
|
||||
|
||||
export const callEventNormalizeSchema = z
|
||||
.object({
|
||||
@@ -293,13 +290,13 @@ export const callEventNormalizeSchema = z
|
||||
type: z
|
||||
.nativeEnum(Proto.SyncMessage.CallEvent.Type)
|
||||
.refine(val => val === Proto.SyncMessage.CallEvent.Type.AD_HOC_CALL),
|
||||
peerId: roomIdInBytesSchema,
|
||||
conversationId: roomIdInBytesSchema,
|
||||
}),
|
||||
z.object({
|
||||
type: z
|
||||
.nativeEnum(Proto.SyncMessage.CallEvent.Type)
|
||||
.refine(val => val !== Proto.SyncMessage.CallEvent.Type.AD_HOC_CALL),
|
||||
peerId: conversationPeerIdInBytesSchema,
|
||||
conversationId: conversationPeerIdInBytesSchema,
|
||||
}),
|
||||
])
|
||||
);
|
||||
|
||||
@@ -81,7 +81,7 @@ export function shouldPreviewHref(href: string): boolean {
|
||||
|
||||
export function isValidLinkPreview(
|
||||
urlsInBody: Array<string>,
|
||||
preview: LinkPreviewType | Backups.ILinkPreview,
|
||||
preview: LinkPreviewType | Backups.LinkPreview.Params,
|
||||
{ isStory }: { isStory: boolean }
|
||||
): boolean {
|
||||
const { url } = preview;
|
||||
|
||||
@@ -463,7 +463,7 @@ function decryptSticker(packKey: string, ciphertext: Uint8Array): Uint8Array {
|
||||
async function downloadSticker(
|
||||
packId: string,
|
||||
packKey: string,
|
||||
proto: Proto.StickerPack.ISticker,
|
||||
proto: Proto.StickerPack.Sticker.Params,
|
||||
{ ephemeral }: { ephemeral?: boolean } = {}
|
||||
): Promise<Omit<StickerFromDBType, 'isCoverOnly'>> {
|
||||
const { id, emoji } = proto;
|
||||
@@ -628,7 +628,7 @@ export async function downloadEphemeralPack(
|
||||
stickerPackAdded(pack);
|
||||
|
||||
const downloadStickerJob = async (
|
||||
stickerProto: Proto.StickerPack.ISticker
|
||||
stickerProto: Proto.StickerPack.Sticker.Params
|
||||
): Promise<boolean> => {
|
||||
let stickerInfo;
|
||||
try {
|
||||
@@ -793,10 +793,10 @@ async function doDownloadStickerPack(
|
||||
return;
|
||||
}
|
||||
|
||||
let coverProto: Proto.StickerPack.ISticker | undefined;
|
||||
let coverProto: Proto.StickerPack.Sticker.Params | undefined;
|
||||
let coverStickerId: number | undefined;
|
||||
let coverIncludedInList = false;
|
||||
let nonCoverStickers: Array<Proto.StickerPack.ISticker> = [];
|
||||
let nonCoverStickers: Array<Proto.StickerPack.Sticker.Params> = [];
|
||||
|
||||
try {
|
||||
// Synchronous placeholder to help with race conditions
|
||||
@@ -891,7 +891,7 @@ async function doDownloadStickerPack(
|
||||
// and we want to preserve more of the pack on an error.
|
||||
try {
|
||||
const downloadStickerJob = async (
|
||||
stickerProto: Proto.StickerPack.ISticker
|
||||
stickerProto: Proto.StickerPack.Sticker.Params
|
||||
): Promise<boolean> => {
|
||||
try {
|
||||
const stickerInfo = await downloadSticker(
|
||||
|
||||
Reference in New Issue
Block a user