From c88fbe843a10c56dbe74311a8eeb4b6b1e025d7b Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Mon, 30 Oct 2023 01:04:55 +0100 Subject: [PATCH] upd: remove debug lines, fix header not being detected --- .../src/server/api/mastodon/MastodonApiServerService.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts b/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts index cc61a234d..bdf3af058 100644 --- a/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts +++ b/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts @@ -258,27 +258,27 @@ export class MastodonApiServerService { try { if (_request.files.length > 0 && accessTokens) { const tokeninfo = await this.accessTokensRepository.findOneBy({ token: accessTokens.replace('Bearer ', '') }); + // eslint-disable-next-line @typescript-eslint/no-explicit-any const avatar = (_request.files as any).find((obj: any) => { return obj.fieldname === 'avatar'; }); + // eslint-disable-next-line @typescript-eslint/no-explicit-any const header = (_request.files as any).find((obj: any) => { return obj.fieldname === 'header'; }); if (tokeninfo && avatar) { - console.error('avatar'); const upload = await this.driveService.addFile({ user: { id: tokeninfo.userId, host: null }, path: avatar.path, name: avatar.originalname !== null && avatar.originalname !== 'file' ? avatar.originalname : undefined, sensitive: false, }); - console.error(upload); if (upload.type.startsWith('image/')) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any (_request.body as any).avatar = upload.id; } - } - if (tokeninfo && (_request.files as any)['header']) { + } else if (tokeninfo && header) { const upload = await this.driveService.addFile({ user: { id: tokeninfo.userId, host: null }, path: header.path, @@ -286,6 +286,7 @@ export class MastodonApiServerService { sensitive: false, }); if (upload.type.startsWith('image/')) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any (_request.body as any).header = upload.id; } }