From 8f77350089eebcf4fe07eb9fadd7cff9ea9fef11 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 23 Sep 2023 12:38:20 +0900 Subject: [PATCH] =?UTF-8?q?enhance:=20PWA=E3=81=AEshort=5Fname=E3=82=92?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E5=8F=AF=E8=83=BD=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + locales/index.d.ts | 2 ++ locales/ja-JP.yml | 2 ++ .../backend/migration/1695440131671-short-name.js | 11 +++++++++++ packages/backend/src/models/Meta.ts | 5 +++++ .../backend/src/server/api/endpoints/admin/meta.ts | 1 + .../src/server/api/endpoints/admin/update-meta.ts | 5 +++++ .../backend/src/server/web/ClientServerService.ts | 4 ++-- packages/frontend/src/pages/admin/settings.vue | 8 ++++++++ packages/misskey-js/etc/misskey-js.api.md | 1 + packages/misskey-js/src/entities.ts | 1 + 11 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 packages/backend/migration/1695440131671-short-name.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 778e6cee1c..dc99ee33fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - Feat: プロフィールでのリンク検証 - Feat: 通知をテストできるようになりました - Feat: PWAのアイコンが設定できるようになりました +- Enhance: サーバー名の略称が設定できるようになりました - Enhance: アンテナの受信ソースに指定したユーザを除外するものを追加 - Enhance: 二要素認証設定時のセキュリティを強化 - パスワード入力が必要な操作を行う際、二要素認証が有効であれば確認コードの入力も必要になりました diff --git a/locales/index.d.ts b/locales/index.d.ts index dbd485379f..da60550193 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -1158,6 +1158,8 @@ export interface Locale { "appIconStyleRecommendation": string; "appIconResolutionMustBe": string; "manifestJsonOverride": string; + "shortName": string; + "shortNameDescription": string; }; "_accountMigration": { "moveFrom": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index ae32891018..0869c0c455 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1156,6 +1156,8 @@ _serverSettings: appIconStyleRecommendation: "円形もしくは角丸にクロップされる場合があるため、塗り潰された余白のある背景を持つことが推奨されます。" appIconResolutionMustBe: "解像度は必ず{resolution}である必要があります。" manifestJsonOverride: "manifest.jsonのオーバーライド" + shortName: "略称" + shortNameDescription: "サーバーの正式名称が長い場合に、代わりに表示することのできる略称や通称。" _accountMigration: moveFrom: "別のアカウントからこのアカウントに移行" diff --git a/packages/backend/migration/1695440131671-short-name.js b/packages/backend/migration/1695440131671-short-name.js new file mode 100644 index 0000000000..2c37297fc1 --- /dev/null +++ b/packages/backend/migration/1695440131671-short-name.js @@ -0,0 +1,11 @@ +export class ShortName1695440131671 { + name = 'ShortName1695440131671' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" ADD "shortName" character varying(64)`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "shortName"`); + } +} diff --git a/packages/backend/src/models/Meta.ts b/packages/backend/src/models/Meta.ts index a9e116341f..e69bef8e98 100644 --- a/packages/backend/src/models/Meta.ts +++ b/packages/backend/src/models/Meta.ts @@ -20,6 +20,11 @@ export class MiMeta { }) public name: string | null; + @Column('varchar', { + length: 64, nullable: true, + }) + public shortName: string | null; + @Column('varchar', { length: 1024, nullable: true, }) diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index fe9c134d84..c3ba07cdd0 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -321,6 +321,7 @@ export default class extends Endpoint { // eslint- maintainerEmail: instance.maintainerEmail, version: this.config.version, name: instance.name, + shortName: instance.shortName, uri: this.config.url, description: instance.description, langs: instance.langs, diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index 614e0a95d7..eabf1f306c 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -44,6 +44,7 @@ export const paramDef = { backgroundImageUrl: { type: 'string', nullable: true }, logoImageUrl: { type: 'string', nullable: true }, name: { type: 'string', nullable: true }, + shortName: { type: 'string', nullable: true }, description: { type: 'string', nullable: true }, defaultLightTheme: { type: 'string', nullable: true }, defaultDarkTheme: { type: 'string', nullable: true }, @@ -188,6 +189,10 @@ export default class extends Endpoint { // eslint- set.name = ps.name; } + if (ps.shortName !== undefined) { + set.shortName = ps.shortName; + } + if (ps.description !== undefined) { set.description = ps.description; } diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts index 7b1dd92d73..1faff24201 100644 --- a/packages/backend/src/server/web/ClientServerService.ts +++ b/packages/backend/src/server/web/ClientServerService.ts @@ -114,10 +114,10 @@ export class ClientServerService { let manifest = { // 空文字列の場合右辺を使いたいため // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - 'short_name': instance.name || 'Misskey', + 'short_name': instance.shortName || instance.name || this.config.host, // 空文字列の場合右辺を使いたいため // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - 'name': instance.name || 'Misskey', + 'name': instance.name || this.config.host, 'start_url': '/', 'display': 'standalone', 'background_color': '#313a42', diff --git a/packages/frontend/src/pages/admin/settings.vue b/packages/frontend/src/pages/admin/settings.vue index adcf061149..f93678d728 100644 --- a/packages/frontend/src/pages/admin/settings.vue +++ b/packages/frontend/src/pages/admin/settings.vue @@ -14,6 +14,11 @@ SPDX-License-Identifier: AGPL-3.0-only + + + + + @@ -118,6 +123,7 @@ import { definePageMetadata } from '@/scripts/page-metadata.js'; import MkButton from '@/components/MkButton.vue'; let name: string | null = $ref(null); +let shortName: string | null = $ref(null); let description: string | null = $ref(null); let maintainerName: string | null = $ref(null); let maintainerEmail: string | null = $ref(null); @@ -133,6 +139,7 @@ let deeplIsPro: boolean = $ref(false); async function init(): Promise { const meta = await os.api('admin/meta'); name = meta.name; + shortName = meta.shortName; description = meta.description; maintainerName = meta.maintainerName; maintainerEmail = meta.maintainerEmail; @@ -149,6 +156,7 @@ async function init(): Promise { function save(): void { os.apiWithDialog('admin/update-meta', { name, + shortName: shortName === '' ? null : shortName, description, maintainerName, maintainerEmail, diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index d72652bd92..5cd679bce5 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -2404,6 +2404,7 @@ type LiteInstanceMetadata = { maintainerEmail: string | null; version: string; name: string | null; + shortName: string | null; uri: string; description: string | null; langs: string[]; diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index 9a0114d71c..034201f9b9 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -298,6 +298,7 @@ export type LiteInstanceMetadata = { maintainerEmail: string | null; version: string; name: string | null; + shortName: string | null; uri: string; description: string | null; langs: string[];