Merge tag '13.11.0' into io
# Conflicts: # packages/backend/src/server/ServerService.ts # packages/backend/src/server/api/endpoints/notes/timeline.ts
This commit is contained in:
commit
0e4fe59d57
650 changed files with 32472 additions and 9221 deletions
|
@ -1,8 +1,10 @@
|
|||
import cluster from 'node:cluster';
|
||||
import os from 'node:os';
|
||||
import * as fs from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
|
||||
import Fastify, { FastifyInstance } from 'fastify';
|
||||
import fastifyStatic from '@fastify/static';
|
||||
import { IsNull } from 'typeorm';
|
||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||
import type { Config } from '@/config.js';
|
||||
|
@ -22,6 +24,9 @@ import { StreamingApiServerService } from './api/StreamingApiServerService.js';
|
|||
import { WellKnownServerService } from './WellKnownServerService.js';
|
||||
import { FileServerService } from './FileServerService.js';
|
||||
import { ClientServerService } from './web/ClientServerService.js';
|
||||
import { OpenApiServerService } from './api/openapi/OpenApiServerService.js';
|
||||
|
||||
const _dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
|
||||
@Injectable()
|
||||
export class ServerService implements OnApplicationShutdown {
|
||||
|
@ -43,6 +48,7 @@ export class ServerService implements OnApplicationShutdown {
|
|||
|
||||
private userEntityService: UserEntityService,
|
||||
private apiServerService: ApiServerService,
|
||||
private openApiServerService: OpenApiServerService,
|
||||
private streamingApiServerService: StreamingApiServerService,
|
||||
private activityPubServerService: ActivityPubServerService,
|
||||
private wellKnownServerService: WellKnownServerService,
|
||||
|
@ -72,13 +78,15 @@ export class ServerService implements OnApplicationShutdown {
|
|||
});
|
||||
}
|
||||
|
||||
const hostname = os.hostname();
|
||||
fastify.addHook('onRequest', (request, reply, done) => {
|
||||
reply.header('x-worker-host', hostname);
|
||||
done();
|
||||
// Register non-serving static server so that the child services can use reply.sendFile.
|
||||
// `root` here is just a placeholder and each call must use its own `rootPath`.
|
||||
fastify.register(fastifyStatic, {
|
||||
root: _dirname,
|
||||
serve: false,
|
||||
});
|
||||
|
||||
fastify.register(this.apiServerService.createServer, { prefix: '/api' });
|
||||
fastify.register(this.openApiServerService.createServer);
|
||||
fastify.register(this.fileServerService.createServer);
|
||||
fastify.register(this.activityPubServerService.createServer);
|
||||
fastify.register(this.nodeinfoServerService.createServer);
|
||||
|
@ -142,13 +150,12 @@ export class ServerService implements OnApplicationShutdown {
|
|||
host: (host == null) || (host === this.config.host) ? IsNull() : host,
|
||||
isSuspended: false,
|
||||
},
|
||||
relations: ['avatar'],
|
||||
});
|
||||
|
||||
reply.header('Cache-Control', 'public, max-age=86400');
|
||||
|
||||
if (user) {
|
||||
reply.redirect(this.userEntityService.getAvatarUrlSync(user));
|
||||
reply.redirect(user.avatarUrl ?? this.userEntityService.getIdenticonUrl(user));
|
||||
} else {
|
||||
reply.redirect('/static-assets/user-unknown.png');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue