summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/web/ClientServerService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/server/web/ClientServerService.ts')
-rw-r--r--packages/backend/src/server/web/ClientServerService.ts96
1 files changed, 51 insertions, 45 deletions
diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts
index a8c420e57d..7b1dd92d73 100644
--- a/packages/backend/src/server/web/ClientServerService.ts
+++ b/packages/backend/src/server/web/ClientServerService.ts
@@ -51,45 +51,6 @@ const assets = `${_dirname}/../../../../../built/_frontend_dist_/`;
const swAssets = `${_dirname}/../../../../../built/_sw_dist_/`;
const viteOut = `${_dirname}/../../../../../built/_vite_/`;
-const manifest = {
- 'short_name': 'Misskey',
- 'name': 'Misskey',
- 'start_url': '/',
- 'display': 'standalone',
- 'background_color': '#313a42',
- 'theme_color': '#86b300',
- 'icons': [
- {
- 'src': '/static-assets/icons/192.png',
- 'sizes': '192x192',
- 'type': 'image/png',
- 'purpose': 'maskable',
- },
- {
- 'src': '/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',
- },
- },
-};
-
@Injectable()
export class ClientServerService {
private logger: Logger;
@@ -148,16 +109,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.name || 'Misskey',
+ // 空文字列の場合右辺を使いたいため
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
+ 'name': instance.name || 'Misskey',
+ '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
@@ -165,6 +170,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',