diff options
author | Raphael Kabo <raphaelkabo@hey.com> | 2024-02-06 09:40:58 +0000 |
---|---|---|
committer | Raphael Kabo <raphaelkabo@hey.com> | 2024-02-06 09:40:58 +0000 |
commit | 01b9dd2c4836f2bfb8fc4ba872de7f17767f7591 (patch) | |
tree | 5dd50c62abeda6ae9b7b4f2861d97f211de1e7f8 /src | |
parent | 9e249e508ead933cb26eba597003a3b4764e27a5 (diff) |
Add NodeInfo
Diffstat (limited to 'src')
-rw-r--r-- | src/routes/activitypub.ts | 55 |
1 files changed, 55 insertions, 0 deletions
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:")) { |