From 1e9a7096e1b2c825f08b03693bedd7dd1aeeaab5 Mon Sep 17 00:00:00 2001 From: limepotato Date: Mon, 17 Jun 2024 13:39:53 -0600 Subject: [PATCH] withdrawal traumatize patch --- packages/backend/src/server/nodeinfo.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/nodeinfo.ts b/packages/backend/src/server/nodeinfo.ts index 65fe5a3f4..018e8d330 100644 --- a/packages/backend/src/server/nodeinfo.ts +++ b/packages/backend/src/server/nodeinfo.ts @@ -97,10 +97,22 @@ const cache = new Cache>>( 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) => { 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"); }); @@ -110,7 +122,7 @@ router.get(nodeinfo2_0path, async (ctx) => { // @ts-ignore 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"); });