From 1bce9e2982d1e868e8e8fea0b0f1190ce5b57b3f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 27 Feb 2025 17:34:35 -0600 Subject: [PATCH] Remove `@/config.ts` import from utils/upload.ts --- packages/ditto/utils/upload.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ditto/utils/upload.ts b/packages/ditto/utils/upload.ts index 6c160bb4..1dcce807 100644 --- a/packages/ditto/utils/upload.ts +++ b/packages/ditto/utils/upload.ts @@ -6,7 +6,6 @@ import { encode } from 'blurhash'; import sharp from 'sharp'; import { AppContext } from '@/app.ts'; -import { Conf } from '@/config.ts'; import { DittoUpload, dittoUploads } from '@/DittoUploads.ts'; import { errorJson } from '@/utils/log.ts'; @@ -22,7 +21,8 @@ export async function uploadFile( meta: FileMeta, signal?: AbortSignal, ): Promise { - const uploader = c.get('uploader'); + const { conf, uploader } = c.var; + if (!uploader) { throw new HTTPException(500, { res: c.json({ error: 'No uploader configured.' }), @@ -31,7 +31,7 @@ export async function uploadFile( const { pubkey, description } = meta; - if (file.size > Conf.maxUploadSize) { + if (file.size > conf.maxUploadSize) { throw new Error('File size is too large.'); } @@ -63,7 +63,7 @@ export async function uploadFile( // If the uploader didn't already, try to get a blurhash and media dimensions. // This requires `MEDIA_ANALYZE=true` to be configured because it comes with security tradeoffs. - if (Conf.mediaAnalyze && (!blurhash || !dim)) { + if (conf.mediaAnalyze && (!blurhash || !dim)) { try { const bytes = await new Response(file.stream()).bytes(); const img = sharp(bytes);