From 01b9dd2c4836f2bfb8fc4ba872de7f17767f7591 Mon Sep 17 00:00:00 2001 From: Raphael Kabo Date: Tue, 6 Feb 2024 09:40:58 +0000 Subject: Add NodeInfo --- package.json | 2 +- src/routes/activitypub.ts | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 60fa957..92c6f34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gathio", - "version": "1.3.0", + "version": "1.3.1", "description": "", "main": "index.js", "type": "module", diff --git a/src/routes/activitypub.ts b/src/routes/activitypub.ts index 2b8fb4a..667a44f 100644 --- a/src/routes/activitypub.ts +++ b/src/routes/activitypub.ts @@ -84,6 +84,61 @@ router.get("/:eventID/m/:hash", async (req: Request, res: Response) => { } }); +router.get("/.well-known/nodeinfo", (req, res) => { + if (!config.general.is_federated) { + return res.status(404).render("404", frontendConfig()); + } + const nodeInfo = { + links: [ + { + rel: "http://nodeinfo.diaspora.software/ns/schema/2.2", + href: `https://${config.general.domain}/.well-known/nodeinfo/2.2`, + }, + ], + }; + res.header( + "Content-Type", + 'application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.1#"', + ).send(nodeInfo); +}); + +router.get("/.well-known/nodeinfo/2.2", async (req, res) => { + const eventCount = await Event.countDocuments(); + + if (!config.general.is_federated) { + return res.status(404).render("404", frontendConfig()); + } + const nodeInfo = { + version: "2.2", + instance: { + name: config.general.site_name, + description: + "Federated, no-registration, privacy-respecting event hosting.", + }, + software: { + name: "Gathio", + version: process.env.npm_package_version || "unknown", + repository: "https://github.com/lowercasename/gathio", + homepage: "https://gath.io", + }, + protocols: ["activitypub"], + services: { + inbound: [], + outbound: [], + }, + openRegistrations: true, + usage: { + users: { + total: eventCount, + }, + }, + }; + res.header( + "Content-Type", + 'application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.1#"', + ).send(nodeInfo); +}); + router.get("/.well-known/webfinger", async (req, res) => { let resource = req.query.resource as string; if (!resource || !resource.includes("acct:")) { -- cgit v1.2.3