[mastodon-client] implement favorited_by
This commit is contained in:
parent
c02fec7f36
commit
a94bf84f04
2 changed files with 22 additions and 6 deletions
|
@ -197,7 +197,19 @@ export function apiStatusMastodon(router: Router): void {
|
|||
router.get<{ Params: { id: string } }>(
|
||||
"/v1/statuses/:id/favourited_by",
|
||||
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 } }>(
|
||||
|
|
|
@ -1487,11 +1487,15 @@ export default class Misskey implements MegalodonInterface {
|
|||
}))
|
||||
}
|
||||
|
||||
public async getStatusFavouritedBy(_id: string): Promise<Response<Array<Entity.Account>>> {
|
||||
return new Promise((_, reject) => {
|
||||
const err = new NoImplementedError('misskey does not support')
|
||||
reject(err)
|
||||
})
|
||||
public async getStatusFavouritedBy(id: string): Promise<Response<Array<Entity.Account>>> {
|
||||
return this.client
|
||||
.post<Array<MisskeyAPI.Entity.Reaction>>('/api/notes/reactions', {
|
||||
noteId: id
|
||||
})
|
||||
.then(res => ({
|
||||
...res,
|
||||
data: res.data.map(n => this.converter.user(n.user))
|
||||
}))
|
||||
}
|
||||
|
||||
public async favouriteStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
|
|
Loading…
Reference in a new issue