diff options
| author | xtex <xtexchooser@duck.com> | 2023-09-10 15:16:00 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-10 16:16:00 +0900 |
| commit | 054ba3fea5ea91abaa2ec0c004937ace17b427ed (patch) | |
| tree | 83bddfe987358f4923967ba80d39f14ff86c6eb9 /packages | |
| parent | enhance: センシティブチャンネルはユーザーのノート一覧... (diff) | |
| download | sharkey-054ba3fea5ea91abaa2ec0c004937ace17b427ed.tar.gz sharkey-054ba3fea5ea91abaa2ec0c004937ace17b427ed.tar.bz2 sharkey-054ba3fea5ea91abaa2ec0c004937ace17b427ed.zip | |
feat: nodeinfo 2.1 (#11805)
* feat: enable nodeinfo 2.1
Since 9dd06a7621d1745b30ed1c2b1d94d34143dd638e, nodeinfo 2.1 has been released.
Signed-off-by: xtex <xtexchooser@duck.com>
* feat: only add software.repository to nodeinfo 2.1
https://github.com/jhass/nodeinfo/commit/e54c48e171b6f6bed6fbe2b6c0bdd8d3c16f7909
Signed-off-by: xtex <xtexchooser@duck.com>
* feat: add software.homepage url to nodeinfo 2.1
https://github.com/jhass/nodeinfo/commit/507822cb3c16d84dac884d878e32825ade54028d
Signed-off-by: xtex <xtexchooser@duck.com>
* fix: set proper Content-Type for nodeinfo
Signed-off-by: xtex <xtexchooser@duck.com>
* style: fix lint warnings
Signed-off-by: xtex <xtexchooser@duck.com>
---------
Signed-off-by: xtex <xtexchooser@duck.com>
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/backend/src/server/NodeinfoServerService.ts | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/packages/backend/src/server/NodeinfoServerService.ts b/packages/backend/src/server/NodeinfoServerService.ts index 95cc697768..1a1a3bf5a8 100644 --- a/packages/backend/src/server/NodeinfoServerService.ts +++ b/packages/backend/src/server/NodeinfoServerService.ts @@ -35,10 +35,10 @@ export class NodeinfoServerService { @bindThis public getLinks() { - return [/* (awaiting release) { - rel: 'http://nodeinfo.diaspora.software/ns/schema/2.1', - href: config.url + nodeinfo2_1path - }, */{ + return [{ + rel: 'http://nodeinfo.diaspora.software/ns/schema/2.1', + href: this.config.url + nodeinfo2_1path + }, { rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0', href: this.config.url + nodeinfo2_0path, }]; @@ -46,7 +46,7 @@ export class NodeinfoServerService { @bindThis public createServer(fastify: FastifyInstance, options: FastifyPluginOptions, done: (err?: Error) => void) { - const nodeinfo2 = async () => { + const nodeinfo2 = async (version: number) => { const now = Date.now(); const notesChart = await this.notesChart.getChart('hour', 1, null); @@ -73,11 +73,11 @@ export class NodeinfoServerService { const basePolicies = { ...DEFAULT_POLICIES, ...meta.policies }; - return { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const document: any = { software: { name: 'misskey', version: this.config.version, - repository: meta.repositoryUrl, }, protocols: ['activitypub'], services: { @@ -114,23 +114,36 @@ export class NodeinfoServerService { themeColor: meta.themeColor ?? '#86b300', }, }; + if (version >= 21) { + document.software.repository = meta.repositoryUrl; + document.software.homepage = meta.repositoryUrl; + } + return document; }; const cache = new MemorySingleCache<Awaited<ReturnType<typeof nodeinfo2>>>(1000 * 60 * 10); fastify.get(nodeinfo2_1path, async (request, reply) => { - const base = await cache.fetch(() => nodeinfo2()); + const base = await cache.fetch(() => nodeinfo2(21)); - reply.header('Cache-Control', 'public, max-age=600'); + reply + .type( + 'application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.1#"', + ) + .header('Cache-Control', 'public, max-age=600'); return { version: '2.1', ...base }; }); fastify.get(nodeinfo2_0path, async (request, reply) => { - const base = await cache.fetch(() => nodeinfo2()); + const base = await cache.fetch(() => nodeinfo2(20)); delete (base as any).software.repository; - reply.header('Cache-Control', 'public, max-age=600'); + reply + .type( + 'application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"', + ) + .header('Cache-Control', 'public, max-age=600'); return { version: '2.0', ...base }; }); |