diff --git a/src/server/grpc.ts b/src/server/grpc.ts index 8a11aa3..39625e1 100644 --- a/src/server/grpc.ts +++ b/src/server/grpc.ts @@ -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)), ); diff --git a/src/server/ws/connection.ts b/src/server/ws/connection.ts index e6cf8e1..bd27edf 100644 --- a/src/server/ws/connection.ts +++ b/src/server/ws/connection.ts @@ -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 //