mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 08:53:48 +01:00
[mastodon-client] implement favorited_by
This commit is contained in:
parent
c02fec7f36
commit
a94bf84f04
@ -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 } }>(
|
||||||
|
@ -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>> {
|
||||||
|
Loading…
Reference in New Issue
Block a user