[mastodon-client] implement favorited_by

This commit is contained in:
Laura Hausmann 2023-07-07 22:40:29 +02:00
parent c02fec7f36
commit a94bf84f04
No known key found for this signature in database
GPG Key ID: D044E84C5BE01605
2 changed files with 22 additions and 6 deletions

View File

@ -197,7 +197,19 @@ export function apiStatusMastodon(router: Router): void {
router.get<{ Params: { id: string } }>( router.get<{ Params: { id: string } }>(
"/v1/statuses/:id/favourited_by", "/v1/statuses/:id/favourited_by",
async (ctx) => { async (ctx) => {
ctx.body = []; const BASE_URL = `${ctx.protocol}://${ctx.hostname}`;
const accessTokens = ctx.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const data = await client.getStatusFavouritedBy(
convertId(ctx.params.id, IdType.CalckeyId),
);
ctx.body = data.data.map((account) => convertAccount(account));
} catch (e: any) {
console.error(e);
ctx.status = 401;
ctx.body = e.response.data;
}
}, },
); );
router.post<{ Params: { id: string } }>( router.post<{ Params: { id: string } }>(

View File

@ -1487,11 +1487,15 @@ export default class Misskey implements MegalodonInterface {
})) }))
} }
public async getStatusFavouritedBy(_id: string): Promise<Response<Array<Entity.Account>>> { public async getStatusFavouritedBy(id: string): Promise<Response<Array<Entity.Account>>> {
return new Promise((_, reject) => { return this.client
const err = new NoImplementedError('misskey does not support') .post<Array<MisskeyAPI.Entity.Reaction>>('/api/notes/reactions', {
reject(err) noteId: id
}) })
.then(res => ({
...res,
data: res.data.map(n => this.converter.user(n.user))
}))
} }
public async favouriteStatus(id: string): Promise<Response<Entity.Status>> { public async favouriteStatus(id: string): Promise<Response<Entity.Status>> {