mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-06 05:23:09 +02:00
upd: move media put endpoint into main api file
This commit is contained in:
parent
324cc5509e
commit
0d013ff54f
2 changed files with 12 additions and 16 deletions
|
@ -795,7 +795,18 @@ export class MastodonApiServerService {
|
||||||
NoteEndpoint.votePoll();
|
NoteEndpoint.votePoll();
|
||||||
|
|
||||||
// PUT Endpoint
|
// 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
|
// DELETE Endpoint
|
||||||
NoteEndpoint.deleteStatus();
|
NoteEndpoint.deleteStatus();
|
||||||
|
|
|
@ -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() {
|
public async deleteStatus() {
|
||||||
this.fastify.delete<{ Params: { id: string } }>('/v1/statuses/:id', async (_request, reply) => {
|
this.fastify.delete<{ Params: { id: string } }>('/v1/statuses/:id', async (_request, reply) => {
|
||||||
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
|
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
|
||||||
|
|
Loading…
Reference in a new issue