mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 03:17:38 -07:00
withdrawal traumatize patch
This commit is contained in:
parent
35d88fa3af
commit
1e9a7096e1
1 changed files with 14 additions and 2 deletions
|
@ -97,10 +97,22 @@ const cache = new Cache<Awaited<ReturnType<typeof nodeinfo2>>>(
|
||||||
60 * 10,
|
60 * 10,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// tell sharkey instances that we're mastodon so it properly federates likes
|
||||||
|
const patch = (ctx, base) => {
|
||||||
|
// note: sharkey uses misskey as it's user-agent
|
||||||
|
if ((ctx.get("user-agent") ?? "").toLowerCase().indexOf("misskey") != -1) {
|
||||||
|
const copied = {...base};
|
||||||
|
copied.software = {...copied.software};
|
||||||
|
copied.software.name = 'mastodon';
|
||||||
|
return copied;
|
||||||
|
}
|
||||||
|
return base;
|
||||||
|
};
|
||||||
|
|
||||||
router.get(nodeinfo2_1path, async (ctx) => {
|
router.get(nodeinfo2_1path, async (ctx) => {
|
||||||
const base = await cache.fetch(null, () => nodeinfo2());
|
const base = await cache.fetch(null, () => nodeinfo2());
|
||||||
|
|
||||||
ctx.body = { version: "2.1", ...base };
|
ctx.body = { version: "2.1", ...patch(ctx, base) };
|
||||||
ctx.set("Cache-Control", "public, max-age=600");
|
ctx.set("Cache-Control", "public, max-age=600");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -110,7 +122,7 @@ router.get(nodeinfo2_0path, async (ctx) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
base.software.repository = undefined;
|
base.software.repository = undefined;
|
||||||
|
|
||||||
ctx.body = { version: "2.0", ...base };
|
ctx.body = { version: "2.0", ...patch(ctx, base) };
|
||||||
ctx.set("Cache-Control", "public, max-age=600");
|
ctx.set("Cache-Control", "public, max-age=600");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue