add: source endpoint for editing through masto api
This commit is contained in:
parent
e32b03a048
commit
a12d1c52dd
5 changed files with 37 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import querystring from 'querystring';
|
||||
import { emojiRegexAtStartToEnd } from '@/misc/emoji-regex.js';
|
||||
import { convertId, IdConvertType as IdType, convertAccount, convertAttachment, convertPoll, convertStatus } from '../converters.js';
|
||||
import { convertId, IdConvertType as IdType, convertAccount, convertAttachment, convertPoll, convertStatus, convertStatusSource } from '../converters.js';
|
||||
import { getClient } from '../MastodonApiServerService.js';
|
||||
import { convertTimelinesArgsId, limitToInt } from './timeline.js';
|
||||
import type { Entity } from 'megalodon';
|
||||
|
|
@ -33,6 +33,21 @@ export class ApiStatusMastodon {
|
|||
});
|
||||
}
|
||||
|
||||
public async getStatusSource() {
|
||||
this.fastify.get<{ Params: { id: string } }>('/v1/statuses/:id/source', 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.getStatusSource(convertId(_request.params.id, IdType.SharkeyId));
|
||||
reply.send(convertStatusSource(data.data));
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
reply.code(_request.is404 ? 404 : 401).send(e.response.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async getContext() {
|
||||
this.fastify.get<{ Params: { id: string } }>('/v1/statuses/:id/context', async (_request, reply) => {
|
||||
const BASE_URL = `${_request.protocol}://${_request.hostname}`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue