Skip to content

Commit

Permalink
Merge pull request #130 from lowercasename/rk/nodeinfo
Browse files Browse the repository at this point in the history
Add NodeInfo
  • Loading branch information
lowercasename authored Feb 6, 2024
2 parents 9e249e5 + 01b9dd2 commit b17238e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gathio",
"version": "1.3.0",
"version": "1.3.1",
"description": "",
"main": "index.js",
"type": "module",
Expand Down
55 changes: 55 additions & 0 deletions src/routes/activitypub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:")) {
Expand Down

0 comments on commit b17238e

Please sign in to comment.