diff options
| author | Mar0xy <marie@kaifa.ch> | 2023-09-25 19:15:55 +0200 |
|---|---|---|
| committer | Mar0xy <marie@kaifa.ch> | 2023-09-25 19:15:55 +0200 |
| commit | 0d013ff54f3e41e21fbf8bedb3e8f2f06cbe18f9 (patch) | |
| tree | f127310fa3df43cc18607fbf3e2bf9b4ca163018 /packages/backend/src | |
| parent | fix: adding description not working on media (diff) | |
| download | sharkey-0d013ff54f3e41e21fbf8bedb3e8f2f06cbe18f9.tar.gz sharkey-0d013ff54f3e41e21fbf8bedb3e8f2f06cbe18f9.tar.bz2 sharkey-0d013ff54f3e41e21fbf8bedb3e8f2f06cbe18f9.zip | |
upd: move media put endpoint into main api file
Diffstat (limited to 'packages/backend/src')
| -rw-r--r-- | packages/backend/src/server/api/mastodon/MastodonApiServerService.ts | 13 | ||||
| -rw-r--r-- | packages/backend/src/server/api/mastodon/endpoints/status.ts | 15 |
2 files changed, 12 insertions, 16 deletions
diff --git a/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts b/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts index 128cb3491a..664e5a9b46 100644 --- a/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts +++ b/packages/backend/src/server/api/mastodon/MastodonApiServerService.ts @@ -795,7 +795,18 @@ export class MastodonApiServerService { NoteEndpoint.votePoll(); // PUT Endpoint - NoteEndpoint.updateMedia(); + fastify.put<{ Params: { id: string } }>('/v1/media/:id', { preHandler: upload.none() }, async (_request, reply) => { + const BASE_URL = `${_request.protocol}://${_request.hostname}`; + const accessTokens = _request.headers.authorization; + const client = getClient(BASE_URL, accessTokens); + try { + const data = await client.updateMedia(convertId(_request.params.id, IdType.SharkeyId), _request.body as any); + reply.send(convertAttachment(data.data)); + } catch (e: any) { + /* console.error(e); */ + reply.code(401).send(e.response.data); + } + }); // DELETE Endpoint NoteEndpoint.deleteStatus(); diff --git a/packages/backend/src/server/api/mastodon/endpoints/status.ts b/packages/backend/src/server/api/mastodon/endpoints/status.ts index 991adacb0c..b2c4266fa4 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/status.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/status.ts @@ -368,21 +368,6 @@ export class ApiStatusMastodon { }); } - public async updateMedia() { - this.fastify.put<{ Params: { id: string } }>('/v1/media/:id', async (_request, reply) => { - const BASE_URL = `${_request.protocol}://${_request.hostname}`; - const accessTokens = _request.headers.authorization; - const client = getClient(BASE_URL, accessTokens); - try { - const data = await client.updateMedia(convertId(_request.params.id, IdType.SharkeyId), _request.body as any); - reply.send(convertAttachment(data.data)); - } catch (e: any) { - /* console.error(e); */ - reply.code(401).send(e.response.data); - } - }); - } - public async deleteStatus() { this.fastify.delete<{ Params: { id: string } }>('/v1/statuses/:id', async (_request, reply) => { const BASE_URL = `${_request.protocol}://${_request.hostname}`; |