mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-06 20:16:57 +00:00
follow up of 6c8f21b608
This commit is contained in:
parent
6c8f21b608
commit
474155b677
1 changed files with 24 additions and 1 deletions
|
@ -8,7 +8,7 @@ import { IsNull } from 'typeorm';
|
||||||
import vary from 'vary';
|
import vary from 'vary';
|
||||||
import fastifyAccepts from '@fastify/accepts';
|
import fastifyAccepts from '@fastify/accepts';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { UsersRepository } from '@/models/_.js';
|
import type { MiMeta, UsersRepository } from '@/models/_.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { escapeAttribute, escapeValue } from '@/misc/prelude/xml.js';
|
import { escapeAttribute, escapeValue } from '@/misc/prelude/xml.js';
|
||||||
import type { MiUser } from '@/models/User.js';
|
import type { MiUser } from '@/models/User.js';
|
||||||
|
@ -26,6 +26,9 @@ export class WellKnownServerService {
|
||||||
@Inject(DI.config)
|
@Inject(DI.config)
|
||||||
private config: Config,
|
private config: Config,
|
||||||
|
|
||||||
|
@Inject(DI.meta)
|
||||||
|
private meta: MiMeta,
|
||||||
|
|
||||||
@Inject(DI.usersRepository)
|
@Inject(DI.usersRepository)
|
||||||
private usersRepository: UsersRepository,
|
private usersRepository: UsersRepository,
|
||||||
|
|
||||||
|
@ -66,6 +69,11 @@ export class WellKnownServerService {
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.get('/.well-known/host-meta', async (request, reply) => {
|
fastify.get('/.well-known/host-meta', async (request, reply) => {
|
||||||
|
if (this.meta.federation === 'none') {
|
||||||
|
reply.code(403);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
reply.header('Content-Type', xrd);
|
reply.header('Content-Type', xrd);
|
||||||
return XRD({ element: 'Link', attributes: {
|
return XRD({ element: 'Link', attributes: {
|
||||||
rel: 'lrdd',
|
rel: 'lrdd',
|
||||||
|
@ -75,6 +83,11 @@ export class WellKnownServerService {
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.get('/.well-known/host-meta.json', async (request, reply) => {
|
fastify.get('/.well-known/host-meta.json', async (request, reply) => {
|
||||||
|
if (this.meta.federation === 'none') {
|
||||||
|
reply.code(403);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
reply.header('Content-Type', 'application/json');
|
reply.header('Content-Type', 'application/json');
|
||||||
return {
|
return {
|
||||||
links: [{
|
links: [{
|
||||||
|
@ -86,6 +99,11 @@ export class WellKnownServerService {
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.get('/.well-known/nodeinfo', async (request, reply) => {
|
fastify.get('/.well-known/nodeinfo', async (request, reply) => {
|
||||||
|
if (this.meta.federation === 'none') {
|
||||||
|
reply.code(403);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return { links: this.nodeinfoServerService.getLinks() };
|
return { links: this.nodeinfoServerService.getLinks() };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -99,6 +117,11 @@ fastify.get('/.well-known/change-password', async (request, reply) => {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fastify.get<{ Querystring: { resource: string } }>(webFingerPath, async (request, reply) => {
|
fastify.get<{ Querystring: { resource: string } }>(webFingerPath, async (request, reply) => {
|
||||||
|
if (this.meta.federation === 'none') {
|
||||||
|
reply.code(403);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const fromId = (id: MiUser['id']): FindOptionsWhere<MiUser> => ({
|
const fromId = (id: MiUser['id']): FindOptionsWhere<MiUser> => ({
|
||||||
id,
|
id,
|
||||||
host: IsNull(),
|
host: IsNull(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue