From 7c03d37caa3107c4e21f60563a6f19979d0a509b Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 14 May 2019 02:57:04 +0900 Subject: [PATCH] Add ToSUrl, repositoryUrl, feedbackUrl (#4921) * Add ToSUrl, repositoryUrl, feedbackUrl * modify nodeinfo --- CONTRIBUTING.md | 10 ++++++ locales/ja-JP.yml | 8 +++++ migration/1557761316509-AddSomeUrls.ts | 16 +++++++++ src/client/app/admin/views/instance.vue | 12 +++++++ .../app/common/views/components/nav.vue | 17 ++++++++-- .../app/common/views/components/signup.vue | 10 ++++-- src/models/entities/meta.ts | 20 +++++++++++ src/server/api/endpoints/admin/update-meta.ts | 33 +++++++++++++++++++ src/server/api/endpoints/meta.ts | 3 ++ src/server/nodeinfo.ts | 6 ++++ 10 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 migration/1557761316509-AddSomeUrls.ts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index edc6244d39..c0c72c4704 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -197,3 +197,13 @@ const user = await Users.findOne(userId).then(ensure); // } // の糖衣構文のような扱いです ``` + +### Migration作成方法 +コードの変更をした後、`ormconfig.json`(書き方はCONTRIBUTING.mdを参照)を用意し、 + +``` +npm i -g ts-node +ts-node ./node_modules/typeorm/cli.js migration:generate -n 変更の名前 +``` + +作成されたスクリプトは不必要な変更を含むため除去してください。 diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 14b8daad48..c3bb4f7756 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -508,6 +508,7 @@ common/views/components/nav.vue: repository: "リポジトリ" develop: "開発者" feedback: "フィードバック" + tos: "利用規約" common/views/components/note-menu.vue: mention: "メンション" @@ -628,6 +629,8 @@ common/views/components/signup.vue: password-matched: "確認されました" password-not-matched: "一致していません" recaptcha: "認証" + agree-to: "{0}に同意します。" + tos: "利用規約" create: "アカウント作成" some-error: "何らかの原因によりアカウントの作成に失敗しました。再度お試しください。" @@ -1215,10 +1218,15 @@ admin/views/instance.vue: instance-name: "インスタンス名" instance-description: "インスタンスの紹介" host: "ホスト" + icon-url: "アイコンURL" + logo-url: "ロゴURL" banner-url: "バナー画像URL" error-image-url: "エラー画像URL" languages: "インスタンスの対象言語" languages-desc: "スペースで区切って複数設定できます。" + tos-url: "利用規約URL" + repository-url: "リポジトリURL" + feedback-url: "フィードバックURL" maintainer-config: "管理者情報" maintainer-name: "管理者名" maintainer-email: "管理者の連絡先" diff --git a/migration/1557761316509-AddSomeUrls.ts b/migration/1557761316509-AddSomeUrls.ts new file mode 100644 index 0000000000..a0a2c7970a --- /dev/null +++ b/migration/1557761316509-AddSomeUrls.ts @@ -0,0 +1,16 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class AddSomeUrls1557761316509 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "meta" ADD "ToSUrl" character varying(512)`); + await queryRunner.query(`ALTER TABLE "meta" ADD "repositoryUrl" character varying(512) NOT NULL DEFAULT 'https://github.com/syuilo/misskey'`); + await queryRunner.query(`ALTER TABLE "meta" ADD "feedbackUrl" character varying(512) DEFAULT 'https://github.com/syuilo/misskey/issues/new'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "feedbackUrl"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "repositoryUrl"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "ToSUrl"`); + } +} diff --git a/src/client/app/admin/views/instance.vue b/src/client/app/admin/views/instance.vue index d81edc8fe6..3bbe6579d3 100644 --- a/src/client/app/admin/views/instance.vue +++ b/src/client/app/admin/views/instance.vue @@ -10,6 +10,9 @@ {{ $t('logo-url') }} {{ $t('banner-url') }} {{ $t('error-image-url') }} + {{ $t('tos-url') }} + {{ $t('repository-url') }} + {{ $t('feedback-url') }} {{ $t('languages') }}
@@ -156,6 +159,9 @@ export default Vue.extend({ host: toUnicode(host), maintainerName: null, maintainerEmail: null, + ToSUrl: null, + repositoryUrl: "https://github.com/syuilo/misskey", + feedbackUrl: null, disableRegistration: false, disableLocalTimeline: false, disableGlobalTimeline: false, @@ -207,6 +213,9 @@ export default Vue.extend({ this.$root.getMeta(true).then(meta => { this.maintainerName = meta.maintainerName; this.maintainerEmail = meta.maintainerEmail; + this.ToSUrl = meta.ToSUrl; + this.repositoryUrl = meta.repositoryUrl; + this.feedbackUrl = meta.feedbackUrl; this.disableRegistration = meta.disableRegistration; this.disableLocalTimeline = meta.disableLocalTimeline; this.disableGlobalTimeline = meta.disableGlobalTimeline; @@ -268,6 +277,9 @@ export default Vue.extend({ this.$root.api('admin/update-meta', { maintainerName: this.maintainerName, maintainerEmail: this.maintainerEmail, + ToSUrl: this.ToSUrl, + repositoryUrl: this.repositoryUrl, + feedbackUrl: this.feedbackUrl, disableRegistration: this.disableRegistration, disableLocalTimeline: this.disableLocalTimeline, disableGlobalTimeline: this.disableGlobalTimeline, diff --git a/src/client/app/common/views/components/nav.vue b/src/client/app/common/views/components/nav.vue index 9d4e7091b5..da26fd1b8e 100644 --- a/src/client/app/common/views/components/nav.vue +++ b/src/client/app/common/views/components/nav.vue @@ -1,12 +1,16 @@ @@ -21,8 +25,17 @@ export default Vue.extend({ return { aboutUrl: `/docs/${lang}/about`, repositoryUrl: 'https://github.com/syuilo/misskey', - feedbackUrl: 'https://github.com/syuilo/misskey/issues/new' + feedbackUrl: 'https://github.com/syuilo/misskey/issues/new', + ToSUrl: null } + }, + + mounted() { + this.$root.getMeta(true).then(meta => { + this.repositoryUrl = meta.repositoryUrl; + this.feedbackUrl = meta.feedbackUrl; + this.ToSUrl = meta.ToSUrl; + }) } }); diff --git a/src/client/app/common/views/components/signup.vue b/src/client/app/common/views/components/signup.vue index 9b1df79771..bf8e5d25b8 100644 --- a/src/client/app/common/views/components/signup.vue +++ b/src/client/app/common/views/components/signup.vue @@ -37,8 +37,13 @@

{{ $t('password-not-matched') }}

+ + + {{ $t('tos') }} + +
- {{ $t('create') }} + {{ $t('create') }} @@ -64,7 +69,8 @@ export default Vue.extend({ usernameState: null, passwordStrength: '', passwordRetypeState: null, - meta: null + meta: {}, + ToSAgreement: false } }, diff --git a/src/models/entities/meta.ts b/src/models/entities/meta.ts index 2c36b8333f..c3797a9ed6 100644 --- a/src/models/entities/meta.ts +++ b/src/models/entities/meta.ts @@ -268,4 +268,24 @@ export class Meta { nullable: true }) public discordClientSecret: string | null; + + @Column('varchar', { + length: 512, + nullable: true + }) + public ToSUrl: string | null; + + @Column('varchar', { + length: 512, + default: 'https://github.com/syuilo/misskey', + nullable: false + }) + public repositoryUrl: string; + + @Column('varchar', { + length: 512, + default: 'https://github.com/syuilo/misskey/issues/new', + nullable: true + }) + public feedbackUrl: string | null; } diff --git a/src/server/api/endpoints/admin/update-meta.ts b/src/server/api/endpoints/admin/update-meta.ts index 8a2019fcc1..e34840e907 100644 --- a/src/server/api/endpoints/admin/update-meta.ts +++ b/src/server/api/endpoints/admin/update-meta.ts @@ -330,6 +330,27 @@ export const meta = { 'ja-JP': 'ServiceWorkerのVAPIDキーペアの秘密鍵' } }, + + ToSUrl: { + validator: $.optional.nullable.str, + desc: { + 'ja-JP': '利用規約のURL' + } + }, + + repositoryUrl: { + validator: $.optional.str, + desc: { + 'ja-JP': 'リポジトリのURL' + } + }, + + feedbackUrl: { + validator: $.optional.str, + desc: { + 'ja-JP': 'フィードバックのURL' + } + } } }; @@ -516,6 +537,18 @@ export default define(meta, async (ps) => { set.swPrivateKey = ps.swPrivateKey; } + if (ps.ToSUrl !== undefined) { + set.ToSUrl = ps.ToSUrl; + } + + if (ps.repositoryUrl !== undefined) { + set.repositoryUrl = ps.repositoryUrl; + } + + if (ps.feedbackUrl !== undefined) { + set.feedbackUrl = ps.feedbackUrl; + } + await getConnection().transaction(async transactionalEntityManager => { const meta = await transactionalEntityManager.findOne(Meta, { order: { diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index 5667e7fbb4..e29edae266 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -106,6 +106,9 @@ export default define(meta, async (ps, me) => { uri: config.url, description: instance.description, langs: instance.langs, + ToSUrl: instance.ToSUrl, + repositoryUrl: instance.repositoryUrl, + feedbackUrl: instance.feedbackUrl, secure: config.https != null, machine: os.hostname(), diff --git a/src/server/nodeinfo.ts b/src/server/nodeinfo.ts index d3ad90fab5..da1e4e7b5e 100644 --- a/src/server/nodeinfo.ts +++ b/src/server/nodeinfo.ts @@ -26,6 +26,9 @@ const nodeinfo2 = async () => { maintainerName, maintainerEmail, langs, + ToSUrl, + repositoryUrl, + feedbackUrl, announcements, disableRegistration, disableLocalTimeline, @@ -77,6 +80,9 @@ const nodeinfo2 = async () => { email: maintainerEmail }, langs, + ToSUrl, + repositoryUrl, + feedbackUrl, announcements, disableRegistration, disableLocalTimeline,