mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-26 11:57:34 -07:00
Merge pull request 'feat: Implement reading Announcements from MastoAPI' (#9896) from fruye/calckey:announcements into develop
Reviewed-on: https://codeberg.org/calckey/calckey/pulls/9896
This commit is contained in:
commit
ffa0f13725
1 changed files with 28 additions and 0 deletions
|
@ -62,6 +62,34 @@ export function apiMastodonCompatible(router: Router): void {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get("/v1/announcements", async (ctx) => {
|
||||||
|
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
|
||||||
|
const accessTokens = ctx.request.headers.authorization;
|
||||||
|
const client = getClient(BASE_URL, accessTokens);
|
||||||
|
try {
|
||||||
|
const data = await client.getInstanceAnnouncements();
|
||||||
|
ctx.body = data.data;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.error(e);
|
||||||
|
ctx.status = 401;
|
||||||
|
ctx.body = e.response.data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.post<{ Params: { id: string } }>("/v1/announcements/:id/dismiss", async (ctx) => {
|
||||||
|
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
|
||||||
|
const accessTokens = ctx.request.headers.authorization;
|
||||||
|
const client = getClient(BASE_URL, accessTokens);
|
||||||
|
try {
|
||||||
|
const data = await client.dismissInstanceAnnouncement(ctx.params.id);
|
||||||
|
ctx.body = data.data;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.error(e);
|
||||||
|
ctx.status = 401;
|
||||||
|
ctx.body = e.response.data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
router.get("/v1/filters", async (ctx) => {
|
router.get("/v1/filters", async (ctx) => {
|
||||||
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
|
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
|
||||||
const accessTokens = ctx.request.headers.authorization;
|
const accessTokens = ctx.request.headers.authorization;
|
||||||
|
|
Loading…
Reference in a new issue