diff --git a/server.js b/server.js index e75268a..cd31faa 100644 --- a/server.js +++ b/server.js @@ -128,6 +128,7 @@ app.use('/', routes.core); app.use('/api/inbox', cors(), routes.inbox); app.use('/.well-known/nodeinfo', routes.nodeinfo); app.use('/nodeinfo/2.0', routes.nodeinfo); +app.use('/nodeinfo/2.1', routes.nodeinfo); app.use('/opensearch.xml', routes.opensearch); app.listen(PORT, () => console.log(`App listening on port ${PORT}`)); diff --git a/src/routes/activitypub/nodeinfo.js b/src/routes/activitypub/nodeinfo.js index 99400c3..47d7385 100644 --- a/src/routes/activitypub/nodeinfo.js +++ b/src/routes/activitypub/nodeinfo.js @@ -1,4 +1,8 @@ -// implementation of http://nodeinfo.diaspora.software/protocol.html +// implementation of http://nodeinfo.diaspora.software/ +// TODO: activeMonth and activeHalfyear should be dynamic, currently static +// TODO: enable override of nodeName and nodeDescription from settings +// homepage and repository may want to be updated for user-specific forks +// NB openRegistrations will always be false for a single-instance server import express from 'express'; import { instanceType, instanceVersion } from '../../util.js'; @@ -15,6 +19,10 @@ router.get('/', async (req, res) => { rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0', href: `https://${domain}/nodeinfo/2.0`, }, + { + rel: 'http://nodeinfo.diaspora.software/ns/schema/2.1', + href: `https://${domain}/nodeinfo/2.1`, + }, ], }; res.json(thisNode); @@ -24,7 +32,6 @@ router.get('/', async (req, res) => { const bookmarksDb = req.app.get('bookmarksDb'); const bookmarkCount = await bookmarksDb.getBookmarkCount(); - // TODO: activeMonth and activeHalfyear should be dynamic, currently static const nodeInfo = { version: 2.0, software: { @@ -48,10 +55,45 @@ router.get('/', async (req, res) => { metadata: {}, }; - // spec requires setting this, majority of implementations - // appear to not bother with it? + // spec says servers *should* set this, majority of implementations + // appear to not bother with this detail, but we'll do right by the spec res.type('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"'); + res.json(nodeInfo); + } + + if (req.originalUrl === '/nodeinfo/2.1') { + const bookmarksDb = req.app.get('bookmarksDb'); + const bookmarkCount = await bookmarksDb.getBookmarkCount(); + + const nodeInfo = { + version: 2.1, + software: { + name: instanceType, + version: instanceVersion, + repository: 'https://github.com/ckolderup/postmarks', + homepage: 'https://postmarks.glitch.me', + }, + protocols: ['activitypub'], + services: { + outbound: ['atom1.0'], + inbound: [], + }, + usage: { + users: { + total: 1, + activeMonth: 1, + activeHalfyear: 1, + }, + localPosts: bookmarkCount, + }, + openRegistrations: false, + metadata: { + nodeName: 'Postmarks', + nodeDescription: 'A single-user bookmarking website designed to live on the Fediverse.', + }, + }; + res.type('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.1#"'); res.json(nodeInfo); } });