Merge tag '2023.9.0' into merge-upstream
This commit is contained in:
commit
87223add7b
1235 changed files with 19016 additions and 13835 deletions
|
@ -31,14 +31,13 @@ import { PageEntityService } from '@/core/entities/PageEntityService.js';
|
|||
import { GalleryPostEntityService } from '@/core/entities/GalleryPostEntityService.js';
|
||||
import { ClipEntityService } from '@/core/entities/ClipEntityService.js';
|
||||
import { ChannelEntityService } from '@/core/entities/ChannelEntityService.js';
|
||||
import type { ChannelsRepository, ClipsRepository, FlashsRepository, GalleryPostsRepository, MiMeta, NotesRepository, PagesRepository, UserProfilesRepository, UsersRepository } from '@/models/index.js';
|
||||
import type { ChannelsRepository, ClipsRepository, FlashsRepository, GalleryPostsRepository, MiMeta, NotesRepository, PagesRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||
import type Logger from '@/logger.js';
|
||||
import { deepClone } from '@/misc/clone.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { FlashEntityService } from '@/core/entities/FlashEntityService.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import manifest from './manifest.json' assert { type: 'json' };
|
||||
import { FeedService } from './FeedService.js';
|
||||
import { UrlPreviewService } from './UrlPreviewService.js';
|
||||
import { ClientLoggerService } from './ClientLoggerService.js';
|
||||
|
@ -111,16 +110,60 @@ export class ClientServerService {
|
|||
|
||||
@bindThis
|
||||
private async manifestHandler(reply: FastifyReply) {
|
||||
const res = deepClone(manifest);
|
||||
|
||||
const instance = await this.metaService.fetch(true);
|
||||
|
||||
res.short_name = instance.name ?? 'Misskey';
|
||||
res.name = instance.name ?? 'Misskey';
|
||||
if (instance.themeColor) res.theme_color = instance.themeColor;
|
||||
let manifest = {
|
||||
// 空文字列の場合右辺を使いたいため
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
'short_name': instance.shortName || instance.name || this.config.host,
|
||||
// 空文字列の場合右辺を使いたいため
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
'name': instance.name || this.config.host,
|
||||
'start_url': '/',
|
||||
'display': 'standalone',
|
||||
'background_color': '#313a42',
|
||||
// 空文字列の場合右辺を使いたいため
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
'theme_color': instance.themeColor || '#86b300',
|
||||
'icons': [{
|
||||
// 空文字列の場合右辺を使いたいため
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
'src': instance.app192IconUrl || '/static-assets/icons/192.png',
|
||||
'sizes': '192x192',
|
||||
'type': 'image/png',
|
||||
'purpose': 'maskable',
|
||||
}, {
|
||||
// 空文字列の場合右辺を使いたいため
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
'src': instance.app512IconUrl || '/static-assets/icons/512.png',
|
||||
'sizes': '512x512',
|
||||
'type': 'image/png',
|
||||
'purpose': 'maskable',
|
||||
}, {
|
||||
'src': '/static-assets/splash.png',
|
||||
'sizes': '300x300',
|
||||
'type': 'image/png',
|
||||
'purpose': 'any',
|
||||
}],
|
||||
'share_target': {
|
||||
'action': '/share/',
|
||||
'method': 'GET',
|
||||
'enctype': 'application/x-www-form-urlencoded',
|
||||
'params': {
|
||||
'title': 'title',
|
||||
'text': 'text',
|
||||
'url': 'url',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
manifest = {
|
||||
...manifest,
|
||||
...JSON.parse(instance.manifestJsonOverride === '' ? '{}' : instance.manifestJsonOverride),
|
||||
};
|
||||
|
||||
reply.header('Cache-Control', 'max-age=300');
|
||||
return (res);
|
||||
return (manifest);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
|
@ -128,6 +171,7 @@ export class ClientServerService {
|
|||
return {
|
||||
instanceName: meta.name ?? 'Misskey',
|
||||
icon: meta.iconUrl,
|
||||
appleTouchIcon: meta.app512IconUrl,
|
||||
themeColor: meta.themeColor,
|
||||
serverErrorImageUrl: meta.serverErrorImageUrl ?? 'https://xn--931a.moe/assets/error.jpg',
|
||||
infoImageUrl: meta.infoImageUrl ?? 'https://xn--931a.moe/assets/info.jpg',
|
||||
|
@ -144,21 +188,23 @@ export class ClientServerService {
|
|||
|
||||
// Authenticate
|
||||
fastify.addHook('onRequest', async (request, reply) => {
|
||||
if (request.url === bullBoardPath || request.url.startsWith(bullBoardPath + '/')) {
|
||||
// %71ueueとかでリクエストされたら困るため
|
||||
const url = decodeURI(request.url);
|
||||
if (url === bullBoardPath || url.startsWith(bullBoardPath + '/')) {
|
||||
const token = request.cookies.token;
|
||||
if (token == null) {
|
||||
reply.code(401);
|
||||
throw new Error('login required');
|
||||
reply.code(401).send('Login required');
|
||||
return;
|
||||
}
|
||||
const user = await this.usersRepository.findOneBy({ token });
|
||||
if (user == null) {
|
||||
reply.code(403);
|
||||
throw new Error('no such user');
|
||||
reply.code(403).send('No such user');
|
||||
return;
|
||||
}
|
||||
const isAdministrator = await this.roleService.isAdministrator(user);
|
||||
if (!isAdministrator) {
|
||||
reply.code(403);
|
||||
throw new Error('access denied');
|
||||
reply.code(403).send('Access denied');
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -731,7 +777,7 @@ export class ClientServerService {
|
|||
|
||||
fastify.setErrorHandler(async (error, request, reply) => {
|
||||
const errId = randomUUID();
|
||||
this.clientLoggerService.logger.error(`Internal error occured in ${request.routerPath}: ${error.message}`, {
|
||||
this.clientLoggerService.logger.error(`Internal error occurred in ${request.routerPath}: ${error.message}`, {
|
||||
path: request.routerPath,
|
||||
params: request.params,
|
||||
query: request.query,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue