breaking: move upload form to grpc

This commit is contained in:
Fedor Indutny 2026-04-16 12:48:25 -07:00 committed by GitHub
parent 6588848faa
commit fb9770f781
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 14 deletions

View File

@ -4,7 +4,7 @@
import assert from 'assert';
import { Buffer } from 'buffer';
import createDebug from 'debug';
import { stringify as stringifyUuid } from 'uuid';
import { stringify as stringifyUuid, v4 as uuidv4 } from 'uuid';
import { RequestHandler, buffer, send as sendRaw } from 'micro';
import {
AugmentedRequestHandler as RouteHandler,
@ -272,6 +272,24 @@ export const createHandler = (server: Server): RequestHandler => {
},
);
const onGetUploadForm = grpcRoute(
'org.signal.chat.attachments.Attachments/GetUploadForm',
async () => {
const { cdn, key, headers, signedUploadLocation } =
await server.getAttachmentUploadForm('attachments', uuidv4());
return {
outcome: {
uploadForm: {
cdn,
key,
headers: new Map(Object.entries(headers)),
signedUploadLocation,
},
},
};
},
);
const notFoundAfterAuth: RouteHandler = async (req, res) => {
const device = await auth(server, req, res);
if (!device) {
@ -288,6 +306,7 @@ export const createHandler = (server: Server): RequestHandler => {
onSendMultiRecipientStory,
onLookupUsernameHash,
onLookupUsernameLink,
onGetUploadForm,
...ALL_METHODS.map((method) => method('/*', notFoundAfterAuth)),
);

View File

@ -12,7 +12,6 @@ import {
} from '@signalapp/libsignal-client/zkgroup';
import WebSocket from 'ws';
import { v4 as uuidv4 } from 'uuid';
import { signalservice as Proto } from '../../../protos/compiled';
import { Device } from '../../data/device';
@ -673,18 +672,6 @@ export class Connection extends Service {
return [200, { ok: true }];
});
//
// Attachment upload forms
//
this.router.get('/v4/attachments/form/upload', async () => {
const key = uuidv4();
return [
200,
await this.server.getAttachmentUploadForm('attachments', key),
];
});
//
// Accounts
//