diff options
| author | Raphael <mail@raphaelkabo.com> | 2024-02-06 09:46:56 +0000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-06 09:46:56 +0000 | 
| commit | b17238eb2840553c69fc2dae168be557afbcee9c (patch) | |
| tree | 5dd50c62abeda6ae9b7b4f2861d97f211de1e7f8 | |
| parent | 9e249e508ead933cb26eba597003a3b4764e27a5 (diff) | |
| parent | 01b9dd2c4836f2bfb8fc4ba872de7f17767f7591 (diff) | |
Merge pull request #130 from lowercasename/rk/nodeinfo
Add NodeInfo
| -rw-r--r-- | package.json | 2 | ||||
| -rw-r--r-- | src/routes/activitypub.ts | 55 | 
2 files changed, 56 insertions, 1 deletions
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:")) {  | 
