From 736c8087164fa896dd68705130d438bc1e878378 Mon Sep 17 00:00:00 2001 From: HotoRas Date: Sat, 19 Oct 2024 19:55:04 +0900 Subject: [PATCH 01/22] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 0e2e4c353f6d2fd2cc650007ec2f6a876acde8f7 Author: kakkokari-gtyih Date: Thu Feb 8 20:17:56 2024 +0900 マージミス commit ef762203dd248b09afafaa7c984b4fa5bc6aad85 Merge: 10988b25ce 0f7918c51b Author: kakkokari-gtyih Date: Thu Feb 8 19:02:33 2024 +0900 Merge remote-tracking branch 'msky/develop' into user-approve commit 10988b25ce4bcedaf2728998869a33b2413419ea Author: kakkokari-gtyih Date: Wed Jan 31 10:29:41 2024 +0900 fix commit 3c607f6e92efdb8edce8b9d6da97e716cc59474c Author: kakkokari-gtyih Date: Wed Jan 31 10:25:59 2024 +0900 通常のAPI呼び出し時にも認証状態を確認するように commit 7812e8ba4894c5e9fc7a99a7cedc00526564ec06 Author: kakkokari-gtyih Date: Wed Jan 31 10:17:08 2024 +0900 fix commit 0b2bf7f63a367b39f933ec7bf929530ce5a8faec Merge: bb1c63d1ed 8aea3603a6 Author: kakkokari-gtyih Date: Wed Jan 31 10:13:33 2024 +0900 Merge commit '8aea3603a6486d764656178082a8c365d569e3c3' into user-approve commit bb1c63d1ed26470b714ab3b3d0cf731ce0f9de14 Merge: 4438184cf0 5498ec57d0 Author: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Tue Jan 2 15:07:17 2024 +0900 Merge branch 'develop' into user-approve commit 4438184cf0503766ea60722d73947968fa5b545e Merge: ac7e7f7607 30594dde18 Author: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat Dec 30 00:26:00 2023 +0900 Merge branch 'develop' into user-approve commit ac7e7f7607d865f7317d08b63c1b87cfbf606254 Author: kakkokari-gtyih Date: Sat Dec 30 00:24:45 2023 +0900 fix type issues commit f59198d9c6ac9908654e698296c54126005cedef Author: kakkokari-gtyih Date: Sat Dec 30 00:16:17 2023 +0900 attempting to fix test commit b73b816ddb83faa3bb2d6cbbe247d10fbebfc2a0 Author: kakkokari-gtyih Date: Fri Dec 29 20:37:43 2023 +0900 メッセージをもっと丁寧にした commit 00f03cdef8a593207da7bf033f8b1d4bd5389fef Author: kakkokari-gtyih Date: Fri Dec 29 19:53:55 2023 +0900 文言を変更 commit 711fbc48de71f7a814bd28453a158284f56d80f1 Author: kakkokari-gtyih Date: Fri Dec 29 19:42:09 2023 +0900 メッセージを丁寧にした commit 64927eea3a077b681ed99984982598a6f4199f9b Merge: 794faa5262 7948018e6a Author: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Fri Dec 29 19:17:52 2023 +0900 Merge branch 'develop' into user-approve commit 794faa526266c4060d4ab205ce7eee7ba1fe3e14 Author: kakkokari-gtyih Date: Fri Dec 29 19:16:42 2023 +0900 replace icons commit 5eefb04695c244156bdcd063525c5285cbc9b304 Author: kakkokari-gtyih Date: Fri Dec 29 19:12:04 2023 +0900 fix commit c28685c7faf5f4f3b5d6880dc96f4db82334e5ed Author: kakkokari-gtyih Date: Fri Dec 29 18:21:48 2023 +0900 update migration sql commit 133c372e34562bfba4a76048658e5df0312bfc4e Author: kakkokari-gtyih Date: Fri Dec 29 17:54:23 2023 +0900 fix lint commit 0491b189daa5273a391a02b738b240c742678a0b Author: kakkokari-gtyih Date: Fri Dec 29 17:53:35 2023 +0900 fix commit e52742053ab9bce802c64ce41be0a5c4dc5532ba Author: kakkokari-gtyih Date: Fri Dec 29 17:35:57 2023 +0900 update misskey-js commit eecb4d746f6da54dda512f284f24ec1b713868e3 Author: kakkokari-gtyih Date: Fri Dec 29 17:32:49 2023 +0900 fix jp translation commit 82cda36cb3e30b2f326d4e2f8372c8490b587057 Author: kakkokari-gtyih Date: Fri Dec 29 17:31:34 2023 +0900 インスタンス -> サーバー commit a2344cea9a0d666ba2701ace891c313c0282a92e Author: kakkokari-gtyih Date: Fri Dec 29 17:29:54 2023 +0900 fix frontend errors commit 0ecab3018a949fd6192687fe64f34c3b98cc458f Author: kakkokari-gtyih Date: Fri Dec 29 17:25:30 2023 +0900 use native ref commit e4cf912a6983dc344c6bffe2494a8c872a4fc163 Author: kakkokari-gtyih Date: Fri Dec 29 17:19:40 2023 +0900 fix url commit a3da5adcb1ca99405b394dc9c50f174a63a57a21 Author: kakkokari-gtyih Date: Fri Dec 29 17:17:26 2023 +0900 Update Changelog commit c50fffa40291a662745d2892e0243456b4535fde Author: kakkokari-gtyih Date: Fri Dec 29 17:15:44 2023 +0900 rename commit ea09475504061e9b00d9014704d3cfdaf9f10d08 Author: kakkokari-gtyih Date: Fri Dec 29 17:09:29 2023 +0900 fix translation for crowdin commit d9e54bb83f86d429dc67233998bd642c40da8b62 Author: Mar0xy Date: Sat Oct 21 18:39:13 2023 +0200 upd: send email on new pending approval commit b0ead7d1ef159669dd5bfeeaec0c483c94a6c34a Author: Mar0xy Date: Wed Nov 1 13:56:14 2023 +0100 fix: approval warning showing incorrectly on admin panel commit 9606165b7c614fa4e0bc3b21ac57401439e0b0ff Author: Mar0xy Date: Fri Oct 20 00:13:21 2023 +0200 chore: lint on SkApprovalUser commit 38616fe312458ad2085f2afb77360f525d33e085 Author: Mar0xy Date: Fri Oct 20 00:09:38 2023 +0200 upd: remove approvals from admin-users Removes approvals tab in favor of the new approvals page commit 37a14182c06f5b6071096b1cb0a3e355cfb387e0 Author: Mar0xy Date: Fri Oct 20 00:02:01 2023 +0200 add: approval section in control panel commit d222c79ff8686e330faf1929eb1f221ab829d97b Author: Mar0xy Date: Thu Oct 19 10:42:18 2023 +0200 fix: invite code not being marked as used Fixes an issue where if approval and invite were enabled the code would stay as unused commit 576e13879f284f00bf291c3ad1cc2f711f760b78 Author: Mar0xy Date: Thu Oct 19 10:38:46 2023 +0200 fix: system users not being set to approved on creation commit d71e82369079e86fc6e9c927dcabb723f05bd5c8 Author: Mar0xy Date: Thu Oct 19 10:37:40 2023 +0200 upd: don't show approved badge on remote users commit 71756dbe925c54721e579714490e9a8910b8aa6a Author: Mar0xy Date: Wed Oct 18 23:50:43 2023 +0200 fix: all users being marked as not approved on cards commit 345e1fc551dbd06e0763c1e6251bb1d33f3d682f Author: Mar0xy Date: Wed Oct 18 23:39:48 2023 +0200 upd: show warning in control panel if users are awaiting approval commit 2b0cc5937720b56f58ac2ec1b155bdb3877eb02e Author: Mar0xy Date: Wed Oct 18 23:30:44 2023 +0200 upd: add color to non-approved user cards commit c59770061c9c741077cfbff55b9b0b3c92960c22 Author: kakkokari-gtyih Date: Fri Dec 29 16:49:28 2023 +0900 fix commit 3a521836693a3faaf42eb3f371e04c272af5fa78 Author: Mar0xy Date: Wed Oct 18 21:32:28 2023 +0200 fix: set remote users to approved on updates commit 1ca0d3374f27fe80a26ff4e491da1be2c47b440d Author: Mar0xy Date: Wed Oct 18 21:24:34 2023 +0200 fix: modlog not showing text on approve commit 75e5f5ad0f83d10be80c8c52879db5bae8a8a0b4 Author: kakkokari-gtyih Date: Fri Dec 29 16:44:28 2023 +0900 update api types commit 030177a5678623478f2a7e291e000cf4a8bf9e49 Author: Mar0xy Date: Wed Oct 18 20:56:41 2023 +0200 upd: mark remote users as approved commit 181a946fbb4ef41b499aad55c77080698f8f69db Author: Mar0xy Date: Wed Oct 18 03:40:51 2023 +0200 upd: add `Not Approved` state sorter to Users tab commit 4cbe0cacc840bbbe99e03f1fdd21357330b75642 Author: Mar0xy Date: Wed Oct 18 03:21:06 2023 +0200 upd: handle email signups properly with approval enabled commit e16433bafa8aede289ed807bb61d248739b2681e Author: Mar0xy Date: Wed Oct 18 03:00:48 2023 +0200 add: locales for approval feature commit f69b50a83f3539963e3f8224700bb76fb05c4528 Author: Mar0xy Date: Wed Oct 18 02:41:36 2023 +0200 add: Require Approval for Signup --- Changelog-neko.md | 2 + locales/index.d.ts | 72 ++++++++++ locales/ja-JP.yml | 18 +++ .../migration/1697580470000-approvalSignup.js | 24 ++++ .../src/core/CreateSystemUserService.ts | 1 + .../activitypub/models/ApPersonService.ts | 2 + .../src/core/entities/UserEntityService.ts | 2 + packages/backend/src/models/Meta.ts | 5 + packages/backend/src/models/User.ts | 10 ++ packages/backend/src/models/UserPending.ts | 5 + .../backend/src/models/json-schema/user.ts | 4 + .../backend/src/server/api/ApiCallService.ts | 10 ++ .../backend/src/server/api/EndpointsModule.ts | 4 + .../src/server/api/SigninApiService.ts | 20 +++ .../src/server/api/SignupApiService.ts | 71 ++++++++++ packages/backend/src/server/api/endpoints.ts | 2 + .../api/endpoints/admin/approve-user.ts | 62 +++++++++ .../src/server/api/endpoints/admin/meta.ts | 5 + .../server/api/endpoints/admin/show-user.ts | 2 + .../server/api/endpoints/admin/show-users.ts | 3 +- .../server/api/endpoints/admin/update-meta.ts | 5 + packages/backend/src/types.ts | 6 + packages/backend/test/e2e/users.ts | 2 + packages/frontend/.storybook/fakes.ts | 1 + .../src/components/MkApprovalUser.vue | 123 ++++++++++++++++++ packages/frontend/src/components/MkSignin.vue | 8 ++ .../src/components/MkSignupDialog.form.vue | 14 ++ .../src/components/MkSignupDialog.vue | 6 +- .../src/components/MkVisitorDashboard.vue | 3 + packages/frontend/src/pages/admin-user.vue | 16 +++ .../frontend/src/pages/admin/approvals.vue | 72 ++++++++++ packages/frontend/src/pages/admin/index.vue | 15 +++ .../frontend/src/pages/admin/moderation.vue | 10 ++ .../src/pages/admin/modlog.ModLog.vue | 5 + packages/frontend/src/pages/admin/users.vue | 1 + .../frontend/src/pages/signup-complete.vue | 7 + packages/frontend/src/router/definition.ts | 4 + packages/misskey-js/etc/misskey-js.api.md | 19 +++ .../misskey-js/src/autogen/apiClientJSDoc.ts | 11 ++ packages/misskey-js/src/autogen/endpoint.ts | 2 + packages/misskey-js/src/autogen/entities.ts | 1 + packages/misskey-js/src/autogen/types.ts | 66 +++++++++- packages/misskey-js/src/consts.ts | 7 + packages/misskey-js/src/entities.ts | 3 + 44 files changed, 728 insertions(+), 3 deletions(-) create mode 100644 packages/backend/migration/1697580470000-approvalSignup.js create mode 100644 packages/backend/src/server/api/endpoints/admin/approve-user.ts create mode 100644 packages/frontend/src/components/MkApprovalUser.vue create mode 100644 packages/frontend/src/pages/admin/approvals.vue diff --git a/Changelog-neko.md b/Changelog-neko.md index 908b329060e6..abc6706dd057 100644 --- a/Changelog-neko.md +++ b/Changelog-neko.md @@ -1,6 +1,8 @@ ## Unreleased ### General +- Feat: ユーザー登録を承認制にできるように (cherry-pick from https://git.joinsharkey.org/Sharkey/Sharkey) +- Fix: リストライムラインの「リノートを表示」が正しく機能しない問題を修正 ### Frontend diff --git a/locales/index.d.ts b/locales/index.d.ts index 8e7668ddc5e5..051d063bfaee 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -152,6 +152,10 @@ export interface Locale extends ILocale { * ユーザー */ "users": string; + /** + * 承認 + */ + "approvals": string; /** * ユーザーを追加 */ @@ -612,6 +616,14 @@ export interface Locale extends ILocale { * 凍結しますか? */ "suspendConfirm": string; + /** + * 登録を承認しますか? + */ + "registerApproveConfirm": string; + /** + * この操作は取り消せません。承認後、このユーザーに登録が承認された旨が記載されたメールが送信されます。 + */ + "registerApproveConfirmDescription": string; /** * 解凍しますか? */ @@ -3648,6 +3660,14 @@ export interface Locale extends ILocale { * アカウント登録にメールアドレスを必須にする */ "emailRequiredForSignup": string; + /** + * アカウント登録を承認制にする + */ + "approvalRequiredForSignup": string; + /** + * アカウント登録の承認 + */ + "signupPendingApprovals": string; /** * 未読 */ @@ -3848,6 +3868,10 @@ export interface Locale extends ILocale { * 未対応の通報があります。 */ "thereIsUnresolvedAbuseReportWarning": string; + /** + * 承認待ちのユーザーがいます。 + */ + "pendingUserApprovals": string; /** * 推奨 */ @@ -3880,6 +3904,26 @@ export interface Locale extends ILocale { * アカウント削除 */ "deleteAccount": string; + /** + * 承認する + */ + "approveAccount": string; + /** + * 拒否してアカウント削除 + */ + "denyAccount": string; + /** + * 承認済み + */ + "approved": string; + /** + * 未承認 + */ + "notApproved": string; + /** + * 承認状況 + */ + "approvalStatus": string; /** * ドキュメント */ @@ -4248,6 +4292,22 @@ export interface Locale extends ILocale { * 現在このサーバーは招待制です。招待コードをお持ちの方のみ登録できます。 */ "invitationRequiredToRegister": string; + /** + * 現在このサーバーは承認制です。参加したい理由を記入し、承認された方のみ登録できます。 + */ + "approvalRequiredToRegister": string; + /** + * 登録理由 + */ + "registerReason": string; + /** + * サーバーへの登録はまだ承認されていません。しばらくしてから再度お試しください。登録時にメールアドレスを記入した場合は、登録が承認されたらメールでお知らせします。 + */ + "registerHasNotBeenApprovedYet": string; + /** + * サーバーへの登録が承認されたかどうかの通知を行うために、併せてアカウント登録にメールアドレスを必須にすることを強く推奨します。 + */ + "registerApprovalEmailRecommended": string; /** * このサーバーではメール配信はサポートされていません */ @@ -7017,6 +7077,14 @@ export interface Locale extends ILocale { * 入力されたメールアドレス({email})宛に確認のメールが送信されました。メールに記載されたリンクにアクセスすると、アカウントの作成が完了します。メールに記載されているリンクの有効期限は30分です。 */ "emailSent": ParameterizedString<"email">; + /** + * アカウントが作成され、承認待ちの状態です。 + */ + "approvalPending": string; + /** + * このサーバーに参加したい理由を入力してください。 + */ + "reasonInfo": string; }; "_accountDelete": { /** @@ -9679,6 +9747,10 @@ export interface Locale extends ILocale { * ロールのアサイン解除 */ "unassignRole": string; + /** + * 承認済み + */ + "approve": string; /** * 凍結 */ diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index ebd8ad64f490..0a28bf31b504 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -34,6 +34,7 @@ signup: "新規登録" uploading: "アップロード中" save: "保存" users: "ユーザー" +approvals: "承認" addUser: "ユーザーを追加" favorite: "お気に入り" favorites: "お気に入り" @@ -149,6 +150,8 @@ unsuspend: "解凍" blockConfirm: "ブロックしますか?" unblockConfirm: "ブロック解除しますか?" suspendConfirm: "凍結しますか?" +registerApproveConfirm: "登録を承認しますか?" +registerApproveConfirmDescription: "この操作は取り消せません。承認後、このユーザーに登録が承認された旨が記載されたメールが送信されます。" unsuspendConfirm: "解凍しますか?" selectList: "リストを選択" editList: "リストを編集" @@ -908,6 +911,8 @@ itsOff: "オフになっています" on: "オン" off: "オフ" emailRequiredForSignup: "アカウント登録にメールアドレスを必須にする" +approvalRequiredForSignup: "アカウント登録を承認制にする" +signupPendingApprovals: "アカウント登録の承認" unread: "未読" filter: "フィルタ" controlPanel: "コントロールパネル" @@ -958,6 +963,7 @@ recentNHours: "直近{n}時間" recentNDays: "直近{n}日" noEmailServerWarning: "メールサーバーの設定がされていません。" thereIsUnresolvedAbuseReportWarning: "未対応の通報があります。" +pendingUserApprovals: "承認待ちのユーザーがいます。" recommended: "推奨" check: "チェック" driveCapOverrideLabel: "このユーザーのドライブ容量上限を変更" @@ -966,6 +972,11 @@ requireAdminForView: "閲覧するには管理者アカウントでログイン isSystemAccount: "システムにより自動で作成・管理されているアカウントです。" typeToConfirm: "この操作を行うには {x} と入力してください" deleteAccount: "アカウント削除" +approveAccount: "承認する" +denyAccount: "拒否してアカウント削除" +approved: "承認済み" +notApproved: "未承認" +approvalStatus: "承認状況" document: "ドキュメント" numberOfPageCache: "ページキャッシュ数" numberOfPageCacheDescription: "多くすると利便性が向上しますが、負荷とメモリ使用量が増えます。" @@ -1058,6 +1069,10 @@ disableFederationConfirm: "連合なしにしますか?" disableFederationConfirmWarn: "連合なしにしても投稿は非公開になりません。ほとんどの場合、連合なしにする必要はありません。" disableFederationOk: "連合なしにする" invitationRequiredToRegister: "現在このサーバーは招待制です。招待コードをお持ちの方のみ登録できます。" +approvalRequiredToRegister: "現在このサーバーは承認制です。参加したい理由を記入し、承認された方のみ登録できます。" +registerReason: "登録理由" +registerHasNotBeenApprovedYet: "サーバーへの登録はまだ承認されていません。しばらくしてから再度お試しください。登録時にメールアドレスを記入した場合は、登録が承認されたらメールでお知らせします。" +registerApprovalEmailRecommended: "サーバーへの登録が承認されたかどうかの通知を行うために、併せてアカウント登録にメールアドレスを必須にすることを強く推奨します。" emailNotSupported: "このサーバーではメール配信はサポートされていません" postToTheChannel: "チャンネルに投稿" cannotBeChangedLater: "後から変更できません。" @@ -1817,6 +1832,8 @@ _signup: almostThere: "ほとんど完了です" emailAddressInfo: "あなたが使っているメールアドレスを入力してください。メールアドレスが公開されることはありません。" emailSent: "入力されたメールアドレス({email})宛に確認のメールが送信されました。メールに記載されたリンクにアクセスすると、アカウントの作成が完了します。メールに記載されているリンクの有効期限は30分です。" + approvalPending: "アカウントが作成され、承認待ちの状態です。" + reasonInfo: "このサーバーに参加したい理由を入力してください。" _accountDelete: accountDelete: "アカウントの削除" @@ -2567,6 +2584,7 @@ _moderationLogTypes: updateRole: "ロールを更新" assignRole: "ロールへアサイン" unassignRole: "ロールのアサイン解除" + approve: "承認済み" suspend: "凍結" unsuspend: "凍結解除" addCustomEmoji: "カスタム絵文字追加" diff --git a/packages/backend/migration/1697580470000-approvalSignup.js b/packages/backend/migration/1697580470000-approvalSignup.js new file mode 100644 index 000000000000..61fc0ed64e58 --- /dev/null +++ b/packages/backend/migration/1697580470000-approvalSignup.js @@ -0,0 +1,24 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class ApprovalSignup1697580470000 { + name = 'ApprovalSignup1697580470000' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" ADD "approvalRequiredForSignup" boolean DEFAULT false NOT NULL`); + await queryRunner.query(`ALTER TABLE "user" ADD "approved" boolean DEFAULT false NOT NULL`); + //▼ 既存のユーザーについては全員Approveにする + await queryRunner.query(`UPDATE "user" SET "approved" = true`); + await queryRunner.query(`ALTER TABLE "user" ADD "signupReason" character varying(1000) NULL`); + await queryRunner.query(`ALTER TABLE "user_pending" ADD "reason" character varying(1000) NULL`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "approvalRequiredForSignup"`); + await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "approved"`); + await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "signupReason"`); + await queryRunner.query(`ALTER TABLE "user_pending" DROP COLUMN "reason"`); + } +} diff --git a/packages/backend/src/core/CreateSystemUserService.ts b/packages/backend/src/core/CreateSystemUserService.ts index 6c5b0f6a36ae..71c2db77aba6 100644 --- a/packages/backend/src/core/CreateSystemUserService.ts +++ b/packages/backend/src/core/CreateSystemUserService.ts @@ -60,6 +60,7 @@ export class CreateSystemUserService { isRoot: false, isLocked: true, isExplorable: false, + approved: true, isBot: true, }).then(x => transactionalEntityManager.findOneByOrFail(MiUser, x.identifiers[0])); diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index b1a28e69929d..502a13d2db54 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -349,6 +349,7 @@ export class ApPersonService implements OnModuleInit { alsoKnownAs: person.alsoKnownAs, isExplorable: person.discoverable, username: person.preferredUsername, + approved: true, usernameLower: person.preferredUsername?.toLowerCase(), host, inbox: person.inbox, @@ -521,6 +522,7 @@ export class ApPersonService implements OnModuleInit { emojis: emojiNames, name: truncate(person.name, nameLength), tags, + approved: true, isBot: getApType(object) === 'Service' || getApType(object) === 'Application', isCat: (person as any).isCat === true, isLocked: person.manuallyApprovesFollowers, diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts index 6a59b9733519..6db9440217dd 100644 --- a/packages/backend/src/core/entities/UserEntityService.ts +++ b/packages/backend/src/core/entities/UserEntityService.ts @@ -562,6 +562,7 @@ export class UserEntityService implements OnModuleInit { }))), memo: memo, moderationNote: iAmModerator ? (profile!.moderationNote ?? '') : undefined, + approved: iAmModerator ? user.approved : undefined, } : {}), ...(isDetailed && isMe ? { @@ -611,6 +612,7 @@ export class UserEntityService implements OnModuleInit { ...(opts.includeSecrets ? { email: profile!.email, emailVerified: profile!.emailVerified, + signupReason: user.signupReason, securityKeysList: profile!.twoFactorEnabled ? this.userSecurityKeysRepository.find({ where: { diff --git a/packages/backend/src/models/Meta.ts b/packages/backend/src/models/Meta.ts index d29689f9073a..eeef757f93ef 100644 --- a/packages/backend/src/models/Meta.ts +++ b/packages/backend/src/models/Meta.ts @@ -184,6 +184,11 @@ export class MiMeta { }) public emailRequiredForSignup: boolean; + @Column('boolean', { + default: false, + }) + public approvalRequiredForSignup: boolean; + @Column('boolean', { default: false, }) diff --git a/packages/backend/src/models/User.ts b/packages/backend/src/models/User.ts index 61fd12ec7fe2..3dd46d645bad 100644 --- a/packages/backend/src/models/User.ts +++ b/packages/backend/src/models/User.ts @@ -260,6 +260,16 @@ export class MiUser { }) public token: string | null; + @Column('boolean', { + default: false, + }) + public approved: boolean; + + @Column('varchar', { + length: 1000, nullable: true, + }) + public signupReason: string | null; + constructor(data: Partial) { if (data == null) return; diff --git a/packages/backend/src/models/UserPending.ts b/packages/backend/src/models/UserPending.ts index 99f8a22a8481..961ae344f198 100644 --- a/packages/backend/src/models/UserPending.ts +++ b/packages/backend/src/models/UserPending.ts @@ -31,4 +31,9 @@ export class MiUserPending { length: 128, }) public password: string; + + @Column('varchar', { + length: 1000, + }) + public reason: string; } diff --git a/packages/backend/src/models/json-schema/user.ts b/packages/backend/src/models/json-schema/user.ts index 16c8a5a097bb..f925f0ddc088 100644 --- a/packages/backend/src/models/json-schema/user.ts +++ b/packages/backend/src/models/json-schema/user.ts @@ -382,6 +382,10 @@ export const packedUserDetailedNotMeOnlySchema = { type: 'string', nullable: false, optional: true, }, + approved: { + type: 'boolean', + nullable: false, optional: true, + }, //#region relations isFollowing: { type: 'boolean', diff --git a/packages/backend/src/server/api/ApiCallService.ts b/packages/backend/src/server/api/ApiCallService.ts index aad833f1261e..07d30d3e9bad 100644 --- a/packages/backend/src/server/api/ApiCallService.ts +++ b/packages/backend/src/server/api/ApiCallService.ts @@ -342,6 +342,8 @@ export class ApiCallService implements OnApplicationShutdown { } } + const instance = await this.metaService.fetch(true); + if (ep.meta.requireCredential || ep.meta.requireModerator || ep.meta.requireAdmin) { if (user == null) { throw new ApiError({ @@ -357,6 +359,14 @@ export class ApiCallService implements OnApplicationShutdown { kind: 'permission', id: 'a8c724b3-6e9c-4b46-b1a8-bc3ed6258370', }); + } else if (instance.approvalRequiredForSignup && user!.approved === false) { + throw new ApiError({ + message: 'Your account is not approved yet.', + code: 'YOUR_ACCOUNT_NOT_APPROVED', + kind: 'permission', + id: '2fe70810-0ed2-47db-a70b-dc3ecbf5f069', + httpStatusCode: 403, + }); } } diff --git a/packages/backend/src/server/api/EndpointsModule.ts b/packages/backend/src/server/api/EndpointsModule.ts index 6e1eedd6b8ca..dbfaa3cf5fdb 100644 --- a/packages/backend/src/server/api/EndpointsModule.ts +++ b/packages/backend/src/server/api/EndpointsModule.ts @@ -74,6 +74,7 @@ import * as ep___admin_showModerationLogs from './endpoints/admin/show-moderatio import * as ep___admin_showUser from './endpoints/admin/show-user.js'; import * as ep___admin_showUsers from './endpoints/admin/show-users.js'; import * as ep___admin_suspendUser from './endpoints/admin/suspend-user.js'; +import * as ep___admin_approveUser from './endpoints/admin/approve-user.js'; import * as ep___admin_unsuspendUser from './endpoints/admin/unsuspend-user.js'; import * as ep___admin_updateMeta from './endpoints/admin/update-meta.js'; import * as ep___admin_deleteAccount from './endpoints/admin/delete-account.js'; @@ -460,6 +461,7 @@ const $admin_showModerationLogs: Provider = { provide: 'ep:admin/show-moderation const $admin_showUser: Provider = { provide: 'ep:admin/show-user', useClass: ep___admin_showUser.default }; const $admin_showUsers: Provider = { provide: 'ep:admin/show-users', useClass: ep___admin_showUsers.default }; const $admin_suspendUser: Provider = { provide: 'ep:admin/suspend-user', useClass: ep___admin_suspendUser.default }; +const $admin_approveUser: Provider = { provide: 'ep:admin/approve-user', useClass: ep___admin_approveUser.default }; const $admin_unsuspendUser: Provider = { provide: 'ep:admin/unsuspend-user', useClass: ep___admin_unsuspendUser.default }; const $admin_updateMeta: Provider = { provide: 'ep:admin/update-meta', useClass: ep___admin_updateMeta.default }; const $admin_deleteAccount: Provider = { provide: 'ep:admin/delete-account', useClass: ep___admin_deleteAccount.default }; @@ -850,6 +852,7 @@ const $reversi_verify: Provider = { provide: 'ep:reversi/verify', useClass: ep__ $admin_showUser, $admin_showUsers, $admin_suspendUser, + $admin_approveUser, $admin_unsuspendUser, $admin_updateMeta, $admin_deleteAccount, @@ -1234,6 +1237,7 @@ const $reversi_verify: Provider = { provide: 'ep:reversi/verify', useClass: ep__ $admin_showUser, $admin_showUsers, $admin_suspendUser, + $admin_approveUser, $admin_unsuspendUser, $admin_updateMeta, $admin_deleteAccount, diff --git a/packages/backend/src/server/api/SigninApiService.ts b/packages/backend/src/server/api/SigninApiService.ts index edac9b3beb62..031bd700d2aa 100644 --- a/packages/backend/src/server/api/SigninApiService.ts +++ b/packages/backend/src/server/api/SigninApiService.ts @@ -20,6 +20,7 @@ import { IdService } from '@/core/IdService.js'; import { bindThis } from '@/decorators.js'; import { WebAuthnService } from '@/core/WebAuthnService.js'; import { UserAuthService } from '@/core/UserAuthService.js'; +import { MetaService } from '@/core/MetaService.js'; import { RateLimiterService } from './RateLimiterService.js'; import { SigninService } from './SigninService.js'; import type { AuthenticationResponseJSON } from '@simplewebauthn/types'; @@ -45,6 +46,7 @@ export class SigninApiService { private signinService: SigninService, private userAuthService: UserAuthService, private webAuthnService: WebAuthnService, + private metaService: MetaService, ) { } @@ -63,6 +65,8 @@ export class SigninApiService { reply.header('Access-Control-Allow-Origin', this.config.url); reply.header('Access-Control-Allow-Credentials', 'true'); + const instance = await this.metaService.fetch(true); + const body = request.body; const username = body['username']; const password = body['password']; @@ -122,6 +126,18 @@ export class SigninApiService { const profile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id }); + if (user.approved === false && instance.approvalRequiredForSignup) { + reply.code(403); + return { + error: { + message: 'Your account is not approved yet.', + code: 'YOUR_ACCOUNT_NOT_APPROVED', + kind: 'permission', + id: '2fe70810-0ed2-47db-a70b-dc3ecbf5f069', + }, + }; + } + // Compare password const same = await bcrypt.compare(password, profile.password!); @@ -140,6 +156,7 @@ export class SigninApiService { if (!profile.twoFactorEnabled) { if (same) { + if (!instance.approvalRequiredForSignup && !user.approved) this.usersRepository.update(user.id, { approved: true }); return this.signinService.signin(request, reply, user); } else { return await fail(403, { @@ -163,6 +180,8 @@ export class SigninApiService { }); } + if (!instance.approvalRequiredForSignup && !user.approved) this.usersRepository.update(user.id, { approved: true }); + return this.signinService.signin(request, reply, user); } else if (body.credential) { if (!same && !profile.usePasswordLessLogin) { @@ -174,6 +193,7 @@ export class SigninApiService { const authorized = await this.webAuthnService.verifyAuthentication(user.id, body.credential); if (authorized) { + if (!instance.approvalRequiredForSignup && !user.approved) this.usersRepository.update(user.id, { approved: true }); return this.signinService.signin(request, reply, user); } else { return await fail(403, { diff --git a/packages/backend/src/server/api/SignupApiService.ts b/packages/backend/src/server/api/SignupApiService.ts index c49963801800..91c322f7c4b6 100644 --- a/packages/backend/src/server/api/SignupApiService.ts +++ b/packages/backend/src/server/api/SignupApiService.ts @@ -20,6 +20,8 @@ import { bindThis } from '@/decorators.js'; import { L_CHARS, secureRndstr } from '@/misc/secure-rndstr.js'; import { SigninService } from './SigninService.js'; import type { FastifyRequest, FastifyReply } from 'fastify'; +import instance from './endpoints/charts/instance.js'; +import { RoleService } from '@/core/RoleService.js'; @Injectable() export class SignupApiService { @@ -51,6 +53,7 @@ export class SignupApiService { private signupService: SignupService, private signinService: SigninService, private emailService: EmailService, + private roleService: RoleService, ) { } @@ -63,6 +66,7 @@ export class SignupApiService { host?: string; invitationCode?: string; emailAddress?: string; + reason?: string; 'hcaptcha-response'?: string; 'g-recaptcha-response'?: string; 'turnstile-response'?: string; @@ -105,6 +109,7 @@ export class SignupApiService { const password = body['password']; const host: string | null = process.env.NODE_ENV === 'test' ? (body['host'] ?? null) : null; const invitationCode = body['invitationCode']; + const reason = body['reason']; const emailAddress = body['emailAddress']; if (this.meta.emailRequiredForSignup) { @@ -120,6 +125,13 @@ export class SignupApiService { } } + if (instance.approvalRequiredForSignup) { + if (reason == null || typeof reason !== 'string') { + reply.code(400); + return; + } + } + let ticket: MiRegistrationTicket | null = null; if (this.meta.disableRegistration) { @@ -188,6 +200,7 @@ export class SignupApiService { email: emailAddress!, username: username, password: hash, + reason: reason, }); const link = `${this.config.url}/signup-complete/${code}`; @@ -203,6 +216,39 @@ export class SignupApiService { }); } + reply.code(204); + return; + } else if (instance.approvalRequiredForSignup) { + const { account } = await this.signupService.signup({ + username, password, host, reason, + }); + + if (emailAddress) { + this.emailService.sendEmail(emailAddress, 'Approval pending', + 'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.', + 'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.'); + } + + if (ticket) { + await this.registrationTicketsRepository.update(ticket.id, { + usedAt: new Date(), + usedBy: account, + usedById: account.id, + }); + } + + const moderators = await this.roleService.getModerators(); + + for (const moderator of moderators) { + const profile = await this.userProfilesRepository.findOneBy({ userId: moderator.id }); + + if (profile?.email) { + this.emailService.sendEmail(profile.email, 'New user awaiting approval', + `A new user called ${account.username} is awaiting approval with the following reason: "${reason}"`, + `A new user called ${account.username} is awaiting approval with the following reason: "${reason}"`); + } + } + reply.code(204); return; } else { @@ -240,6 +286,8 @@ export class SignupApiService { const code = body['code']; + const instance = await this.metaService.fetch(true); + try { const pendingUser = await this.userPendingsRepository.findOneByOrFail({ code }); @@ -250,6 +298,7 @@ export class SignupApiService { const { account, secret } = await this.signupService.signup({ username: pendingUser.username, passwordHash: pendingUser.password, + reason: pendingUser.reason, }); this.userPendingsRepository.delete({ @@ -273,6 +322,28 @@ export class SignupApiService { }); } + if (instance.approvalRequiredForSignup) { + if (pendingUser.email) { + this.emailService.sendEmail(pendingUser.email, 'Approval pending', + 'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.', + 'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.'); + } + + const moderators = await this.roleService.getModerators(); + + for (const moderator of moderators) { + const profile = await this.userProfilesRepository.findOneBy({ userId: moderator.id }); + + if (profile?.email) { + this.emailService.sendEmail(profile.email, 'New user awaiting approval', + `A new user called ${pendingUser.username} is awaiting approval with the following reason: "${pendingUser.reason}"`, + `A new user called ${pendingUser.username} is awaiting approval with the following reason: "${pendingUser.reason}"`); + } + } + + return { pendingApproval: true }; + } + return this.signinService.signin(request, reply, account as MiLocalUser); } catch (err) { throw new FastifyReplyError(400, typeof err === 'string' ? err : (err as Error).toString()); diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index b04ae824cfcb..848e136a6f81 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -80,6 +80,7 @@ import * as ep___admin_showModerationLogs from './endpoints/admin/show-moderatio import * as ep___admin_showUser from './endpoints/admin/show-user.js'; import * as ep___admin_showUsers from './endpoints/admin/show-users.js'; import * as ep___admin_suspendUser from './endpoints/admin/suspend-user.js'; +import * as ep___admin_approveUser from './endpoints/admin/approve-user.js'; import * as ep___admin_unsuspendUser from './endpoints/admin/unsuspend-user.js'; import * as ep___admin_updateMeta from './endpoints/admin/update-meta.js'; import * as ep___admin_deleteAccount from './endpoints/admin/delete-account.js'; @@ -464,6 +465,7 @@ const eps = [ ['admin/show-user', ep___admin_showUser], ['admin/show-users', ep___admin_showUsers], ['admin/suspend-user', ep___admin_suspendUser], + ['admin/approve-user', ep___admin_approveUser], ['admin/unsuspend-user', ep___admin_unsuspendUser], ['admin/update-meta', ep___admin_updateMeta], ['admin/delete-account', ep___admin_deleteAccount], diff --git a/packages/backend/src/server/api/endpoints/admin/approve-user.ts b/packages/backend/src/server/api/endpoints/admin/approve-user.ts new file mode 100644 index 000000000000..93e8a7e19529 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/admin/approve-user.ts @@ -0,0 +1,62 @@ +import { Inject, Injectable } from '@nestjs/common'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import type { UserProfilesRepository, UsersRepository } from '@/models/_.js'; +import { ModerationLogService } from '@/core/ModerationLogService.js'; +import { DI } from '@/di-symbols.js'; +import { EmailService } from '@/core/EmailService.js'; + +export const meta = { + tags: ['admin'], + + requireCredential: true, + requireModerator: true, + kind: 'write:admin:approve-account', +} as const; + +export const paramDef = { + type: 'object', + properties: { + userId: { type: 'string', format: 'misskey:id' }, + }, + required: ['userId'], +} as const; + +@Injectable() +export default class extends Endpoint { // eslint-disable-line import/no-default-export + constructor( + @Inject(DI.usersRepository) + private usersRepository: UsersRepository, + + @Inject(DI.userProfilesRepository) + private userProfilesRepository: UserProfilesRepository, + + private moderationLogService: ModerationLogService, + private emailService: EmailService, + ) { + super(meta, paramDef, async (ps, me) => { + const user = await this.usersRepository.findOneBy({ id: ps.userId }); + + if (user == null) { + throw new Error('user not found'); + } + + const profile = await this.userProfilesRepository.findOneBy({ userId: ps.userId }); + + await this.usersRepository.update(user.id, { + approved: true, + }); + + if (profile?.email) { + this.emailService.sendEmail(profile.email, 'Account Approved', + 'Your Account has been approved have fun socializing!', + 'Your Account has been approved have fun socializing!'); + } + + this.moderationLogService.log(me, 'approve', { + userId: user.id, + userUsername: user.username, + userHost: user.host, + }); + }); + } +} diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index b76ed5c5242f..d7c0000fb146 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -33,6 +33,10 @@ export const meta = { type: 'boolean', optional: false, nullable: false, }, + approvalRequiredForSignup: { + type: 'boolean', + optional: false, nullable: false, + }, enableHcaptcha: { type: 'boolean', optional: false, nullable: false, @@ -546,6 +550,7 @@ export default class extends Endpoint { // eslint- inquiryUrl: instance.inquiryUrl, disableRegistration: instance.disableRegistration, emailRequiredForSignup: instance.emailRequiredForSignup, + approvalRequiredForSignup: instance.approvalRequiredForSignup, enableHcaptcha: instance.enableHcaptcha, hcaptchaSiteKey: instance.hcaptchaSiteKey, enableMcaptcha: instance.enableMcaptcha, diff --git a/packages/backend/src/server/api/endpoints/admin/show-user.ts b/packages/backend/src/server/api/endpoints/admin/show-user.ts index 655bd32bce06..044185e76236 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-user.ts @@ -231,6 +231,8 @@ export default class extends Endpoint { // eslint- email: profile.email, emailVerified: profile.emailVerified, followedMessage: profile.followedMessage, + approved: user.approved, + signupReason: user.signupReason, autoAcceptFollowed: profile.autoAcceptFollowed, noCrawle: profile.noCrawle, preventAiLearning: profile.preventAiLearning, diff --git a/packages/backend/src/server/api/endpoints/admin/show-users.ts b/packages/backend/src/server/api/endpoints/admin/show-users.ts index 2fef9abbf966..5f1651940345 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-users.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-users.ts @@ -35,7 +35,7 @@ export const paramDef = { limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, offset: { type: 'integer', default: 0 }, sort: { type: 'string', enum: ['+follower', '-follower', '+createdAt', '-createdAt', '+updatedAt', '-updatedAt', '+lastActiveDate', '-lastActiveDate'] }, - state: { type: 'string', enum: ['all', 'alive', 'available', 'admin', 'moderator', 'adminOrModerator', 'suspended'], default: 'all' }, + state: { type: 'string', enum: ['all', 'alive', 'available', 'admin', 'moderator', 'adminOrModerator', 'suspended', 'approved'], default: 'all' }, origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'combined' }, username: { type: 'string', nullable: true, default: null }, hostname: { @@ -64,6 +64,7 @@ export default class extends Endpoint { // eslint- case 'available': query.where('user.isSuspended = FALSE'); break; case 'alive': query.where('user.updatedAt > :date', { date: new Date(Date.now() - 1000 * 60 * 60 * 24 * 5) }); break; case 'suspended': query.where('user.isSuspended = TRUE'); break; + case 'approved': query.where('user.approved = FALSE'); break; case 'admin': { const adminIds = await this.roleService.getAdministratorIds(); if (adminIds.length === 0) return []; 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 daef236397da..068db2565b38 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -65,6 +65,7 @@ export const paramDef = { cacheRemoteFiles: { type: 'boolean' }, cacheRemoteSensitiveFiles: { type: 'boolean' }, emailRequiredForSignup: { type: 'boolean' }, + approvalRequiredForSignup: { type: 'boolean' }, enableHcaptcha: { type: 'boolean' }, hcaptchaSiteKey: { type: 'string', nullable: true }, hcaptchaSecretKey: { type: 'string', nullable: true }, @@ -305,6 +306,10 @@ export default class extends Endpoint { // eslint- set.emailRequiredForSignup = ps.emailRequiredForSignup; } + if (ps.approvalRequiredForSignup !== undefined) { + set.approvalRequiredForSignup = ps.approvalRequiredForSignup; + } + if (ps.enableHcaptcha !== undefined) { set.enableHcaptcha = ps.enableHcaptcha; } diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts index 5854c6b392e3..e2207cb7a08f 100644 --- a/packages/backend/src/types.ts +++ b/packages/backend/src/types.ts @@ -70,6 +70,7 @@ export const userImportableEntities = ['antenna', 'blocking', 'customEmoji', 'fo export const moderationLogTypes = [ 'updateServerSettings', 'suspend', + 'approve', 'unsuspend', 'updateUserNote', 'addCustomEmoji', @@ -128,6 +129,11 @@ export type ModerationLogPayloads = { userUsername: string; userHost: string | null; }; + approve: { + userId: string; + userUsername: string; + userHost: string | null; + }; unsuspend: { userId: string; userUsername: string; diff --git a/packages/backend/test/e2e/users.ts b/packages/backend/test/e2e/users.ts index 8ebe9af792a9..8838bb5a19ce 100644 --- a/packages/backend/test/e2e/users.ts +++ b/packages/backend/test/e2e/users.ts @@ -151,6 +151,7 @@ describe('ユーザー', () => { policies: user.policies, ...(security ? { email: user.email, + signupReason: user.signupReason, emailVerified: user.emailVerified, securityKeysList: user.securityKeysList, } : {}), @@ -386,6 +387,7 @@ describe('ユーザー', () => { assert.deepStrictEqual(response.loggedInDays, 0); assert.deepStrictEqual(response.policies, DEFAULT_POLICIES); assert.notStrictEqual(response.email, undefined); + assert.notStrictEqual(response.signupReason, undefined); assert.strictEqual(response.emailVerified, false); assert.deepStrictEqual(response.securityKeysList, []); }); diff --git a/packages/frontend/.storybook/fakes.ts b/packages/frontend/.storybook/fakes.ts index fc3b0334e470..3bea50bf00f6 100644 --- a/packages/frontend/.storybook/fakes.ts +++ b/packages/frontend/.storybook/fakes.ts @@ -213,6 +213,7 @@ export function userLite(id = 'someuserid', username = 'miskist', host: entities username, host, name, + approved: true, onlineStatus: 'unknown', avatarUrl: 'https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/about-icon.png?raw=true', avatarBlurhash: 'eQFRshof5NWBRi},juayfPju53WB?0ofs;s*a{ofjuay^SoMEJR%ay', diff --git a/packages/frontend/src/components/MkApprovalUser.vue b/packages/frontend/src/components/MkApprovalUser.vue new file mode 100644 index 000000000000..edc73c0848e1 --- /dev/null +++ b/packages/frontend/src/components/MkApprovalUser.vue @@ -0,0 +1,123 @@ + + + + + + + diff --git a/packages/frontend/src/components/MkSignin.vue b/packages/frontend/src/components/MkSignin.vue index 7942a84d66f3..761f4189fb92 100644 --- a/packages/frontend/src/components/MkSignin.vue +++ b/packages/frontend/src/components/MkSignin.vue @@ -257,6 +257,14 @@ function loginFailed(err: any): void { showSuspendedDialog(); break; } + case '2fe70810-0ed2-47db-a70b-dc3ecbf5f069': { + os.alert({ + type: 'error', + title: i18n.ts.loginFailed, + text: i18n.ts.registerHasNotBeenApprovedYet, + }); + break; + } case '22d05606-fbcf-421a-a2db-b32610dcfd1b': { os.alert({ type: 'error', diff --git a/packages/frontend/src/components/MkSignupDialog.form.vue b/packages/frontend/src/components/MkSignupDialog.form.vue index 4ab4380ad503..bf4dfa1ba3d9 100644 --- a/packages/frontend/src/components/MkSignupDialog.form.vue +++ b/packages/frontend/src/components/MkSignupDialog.form.vue @@ -62,6 +62,10 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.passwordNotMatched }} + + + + @@ -100,6 +104,7 @@ const props = withDefaults(defineProps<{ const emit = defineEmits<{ (ev: 'signup', user: Misskey.entities.SigninResponse): void; (ev: 'signupEmailPending'): void; + (ev: 'approvalPending'): void; }>(); const host = toUnicode(config.host); @@ -112,6 +117,7 @@ const username = ref(''); const password = ref(''); const retypedPassword = ref(''); const invitationCode = ref(''); +const reason = ref(''); const email = ref(''); const usernameState = ref(null); const emailState = ref(null); @@ -255,6 +261,7 @@ async function onSubmit(): Promise { password: password.value, emailAddress: email.value, invitationCode: invitationCode.value, + reason: reason.value, 'hcaptcha-response': hCaptchaResponse.value, 'm-captcha-response': mCaptchaResponse.value, 'g-recaptcha-response': reCaptchaResponse.value, @@ -267,6 +274,13 @@ async function onSubmit(): Promise { text: i18n.tsx._signup.emailSent({ email: email.value }), }); emit('signupEmailPending'); + } else if (instance.approvalRequiredForSignup) { + os.alert({ + type: 'success', + title: i18n.ts._signup.almostThere, + text: i18n.ts._signup.approvalPending, + }); + emit('approvalPending'); } else { const res = await misskeyApi('signin', { username: username.value, diff --git a/packages/frontend/src/components/MkSignupDialog.vue b/packages/frontend/src/components/MkSignupDialog.vue index 97310d32a64e..91e7d5dd5377 100644 --- a/packages/frontend/src/components/MkSignupDialog.vue +++ b/packages/frontend/src/components/MkSignupDialog.vue @@ -25,7 +25,7 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -63,6 +63,10 @@ function onSignup(res: Misskey.entities.SigninResponse) { function onSignupEmailPending() { dialog.value?.close(); } + +function onApprovalPending() { + dialog.value.close(); +} diff --git a/packages/frontend/src/pages/admin/index.vue b/packages/frontend/src/pages/admin/index.vue index db87bd996d00..6b5014054c74 100644 --- a/packages/frontend/src/pages/admin/index.vue +++ b/packages/frontend/src/pages/admin/index.vue @@ -18,6 +18,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.noInquiryUrlWarning }} {{ i18n.ts.configure }} {{ i18n.ts.noBotProtectionWarning }} {{ i18n.ts.configure }} {{ i18n.ts.noEmailServerWarning }} {{ i18n.ts.configure }} + {{ i18n.ts.pendingUserApprovals }} {{ i18n.ts.check }} @@ -66,6 +67,7 @@ const noBotProtection = computed(() => !instance.disableRegistration && !instanc const noEmailServer = computed(() => !instance.enableEmail); const noInquiryUrl = computed(() => isEmpty(instance.inquiryUrl)); const thereIsUnresolvedAbuseReport = ref(false); +const pendingUserApprovals = ref(false); const currentPage = computed(() => router.currentRef.value.child); misskeyApi('admin/abuse-user-reports', { @@ -75,6 +77,14 @@ misskeyApi('admin/abuse-user-reports', { if (reports.length > 0) thereIsUnresolvedAbuseReport.value = true; }); +misskeyApi('admin/show-users', { + state: 'approved', + origin: 'local', + limit: 1, +}).then(approvals => { + if (approvals.length > 0) pendingUserApprovals.value = true; +}); + const NARROW_THRESHOLD = 600; const ro = new ResizeObserver((entries, observer) => { if (entries.length === 0) return; @@ -111,6 +121,11 @@ const menuDef = computed(() => [{ text: i18n.ts.invite, to: '/admin/invites', active: currentPage.value?.route.name === 'invites', + }, { + icon: 'ti ti-user-check', + text: i18n.ts.signupPendingApprovals, + to: '/admin/approvals', + active: currentPage.value?.route.name === 'approvals', }, { icon: 'ti ti-badges', text: i18n.ts.roles, diff --git a/packages/frontend/src/pages/admin/moderation.vue b/packages/frontend/src/pages/admin/moderation.vue index 54eb95cd51d1..c2fe9dc537fe 100644 --- a/packages/frontend/src/pages/admin/moderation.vue +++ b/packages/frontend/src/pages/admin/moderation.vue @@ -18,6 +18,11 @@ SPDX-License-Identifier: AGPL-3.0-only + + + + + {{ i18n.ts.serverRules }} @@ -128,6 +133,7 @@ import MkFolder from '@/components/MkFolder.vue'; const enableRegistration = ref(false); const emailRequiredForSignup = ref(false); +const approvalRequiredForSignup = ref(false); const sensitiveWords = ref(''); const prohibitedWords = ref(''); const hiddenTags = ref(''); @@ -140,6 +146,7 @@ async function init() { const meta = await misskeyApi('admin/meta'); enableRegistration.value = !meta.disableRegistration; emailRequiredForSignup.value = meta.emailRequiredForSignup; + approvalRequiredForSignup.value = meta.approvalRequiredForSignup; sensitiveWords.value = meta.sensitiveWords.join('\n'); prohibitedWords.value = meta.prohibitedWords.join('\n'); hiddenTags.value = meta.hiddenTags.join('\n'); @@ -167,6 +174,9 @@ function onChange_emailRequiredForSignup(value: boolean) { function save_preservedUsernames() { os.apiWithDialog('admin/update-meta', { + disableRegistration: !enableRegistration.value, + emailRequiredForSignup: emailRequiredForSignup.value, + approvalRequiredForSignup: approvalRequiredForSignup.value, preservedUsernames: preservedUsernames.value.split('\n'), }).then(() => { fetchInstance(true); diff --git a/packages/frontend/src/pages/admin/modlog.ModLog.vue b/packages/frontend/src/pages/admin/modlog.ModLog.vue index 64d7f2584572..7c05273747cf 100644 --- a/packages/frontend/src/pages/admin/modlog.ModLog.vue +++ b/packages/frontend/src/pages/admin/modlog.ModLog.vue @@ -26,6 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only ].includes(log.type), [$style.logRed]: [ 'suspend', + 'approve', 'deleteRole', 'deleteGlobalAnnouncement', 'deleteUserAnnouncement', @@ -45,6 +46,7 @@ SPDX-License-Identifier: AGPL-3.0-only >{{ i18n.ts._moderationLogTypes[log.type] }} : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} + : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} {{ log.info.roleName }} @@ -108,6 +110,9 @@ SPDX-License-Identifier: AGPL-3.0-only + diff --git a/packages/frontend/src/pages/admin/users.vue b/packages/frontend/src/pages/admin/users.vue index d1bbb5b73418..2eb92b0a3456 100644 --- a/packages/frontend/src/pages/admin/users.vue +++ b/packages/frontend/src/pages/admin/users.vue @@ -21,6 +21,7 @@ SPDX-License-Identifier: AGPL-3.0-only + diff --git a/packages/frontend/src/pages/signup-complete.vue b/packages/frontend/src/pages/signup-complete.vue index 8c2f7042cdea..226f08bf8e41 100644 --- a/packages/frontend/src/pages/signup-complete.vue +++ b/packages/frontend/src/pages/signup-complete.vue @@ -46,6 +46,13 @@ function submit() { misskeyApi('signup-pending', { code: props.code, }).then(res => { + if (res.pendingApproval) { + return os.alert({ + type: 'success', + title: i18n.ts._signup.almostThere, + text: i18n.ts._signup.approvalPending, + }); + } return login(res.i, '/'); }).catch(() => { submitting.value = false; diff --git a/packages/frontend/src/router/definition.ts b/packages/frontend/src/router/definition.ts index 75f994b86517..86892e480a60 100644 --- a/packages/frontend/src/router/definition.ts +++ b/packages/frontend/src/router/definition.ts @@ -486,6 +486,10 @@ const routes: RouteDef[] = [{ path: '/system-webhook', name: 'system-webhook', component: page(() => import('@/pages/admin/system-webhook.vue')), + }, { + path: '/approvals', + name: 'approvals', + component: page(() => import('@/pages/admin/approvals.vue')), }, { path: '/', component: page(() => import('@/pages/_empty_.vue')), diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index 5b8a2337352e..3bc49daa2f97 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -89,7 +89,14 @@ type AdminAdCreateResponse = operations['admin___ad___create']['responses']['200 type AdminAdDeleteRequest = operations['admin___ad___delete']['requestBody']['content']['application/json']; // @public (undocumented) +<<<<<<< HEAD type AdminAdListRequest = operations['admin___ad___list']['requestBody']['content']['application/json']; +======= +type AdminApproveUserRequest = operations['admin/approve-user']['requestBody']['content']['application/json']; + +// @public (undocumented) +type AdminAvatarDecorationsCreateRequest = operations['admin/avatar-decorations/create']['requestBody']['content']['application/json']; +>>>>>>> 0e2e4c353f6d2fd2cc650007ec2f6a876acde8f7 // @public (undocumented) type AdminAdListResponse = operations['admin___ad___list']['responses']['200']['content']['application/json']; @@ -1292,6 +1299,7 @@ declare namespace entities { AdminShowUsersRequest, AdminShowUsersResponse, AdminSuspendUserRequest, + AdminApproveUserRequest, AdminUnsuspendUserRequest, AdminUpdateMetaRequest, AdminDeleteAccountRequest, @@ -2423,6 +2431,9 @@ type ModerationLog = { } & ({ type: 'updateServerSettings'; info: ModerationLogPayloads['updateServerSettings']; +} | { + type: 'approve'; + info: ModerationLogPayloads['approve']; } | { type: 'suspend'; info: ModerationLogPayloads['suspend']; @@ -2567,7 +2578,11 @@ type ModerationLog = { }); // @public (undocumented) +<<<<<<< HEAD export const moderationLogTypes: readonly ["updateServerSettings", "suspend", "unsuspend", "updateUserNote", "addCustomEmoji", "updateCustomEmoji", "deleteCustomEmoji", "assignRole", "unassignRole", "createRole", "updateRole", "deleteRole", "clearQueue", "promoteQueue", "deleteDriveFile", "deleteNote", "createGlobalAnnouncement", "createUserAnnouncement", "updateGlobalAnnouncement", "updateUserAnnouncement", "deleteGlobalAnnouncement", "deleteUserAnnouncement", "resetPassword", "suspendRemoteInstance", "unsuspendRemoteInstance", "updateRemoteInstanceNote", "markSensitiveDriveFile", "unmarkSensitiveDriveFile", "resolveAbuseReport", "createInvitation", "createAd", "updateAd", "deleteAd", "createAvatarDecoration", "updateAvatarDecoration", "deleteAvatarDecoration", "unsetUserAvatar", "unsetUserBanner", "createSystemWebhook", "updateSystemWebhook", "deleteSystemWebhook", "createAbuseReportNotificationRecipient", "updateAbuseReportNotificationRecipient", "deleteAbuseReportNotificationRecipient", "deleteAccount", "deletePage", "deleteFlash", "deleteGalleryPost"]; +======= +export const moderationLogTypes: readonly ["updateServerSettings", "suspend", "approve", "unsuspend", "updateUserNote", "addCustomEmoji", "updateCustomEmoji", "deleteCustomEmoji", "assignRole", "unassignRole", "createRole", "updateRole", "deleteRole", "clearQueue", "promoteQueue", "deleteDriveFile", "deleteNote", "createGlobalAnnouncement", "createUserAnnouncement", "updateGlobalAnnouncement", "updateUserAnnouncement", "deleteGlobalAnnouncement", "deleteUserAnnouncement", "resetPassword", "suspendRemoteInstance", "unsuspendRemoteInstance", "markSensitiveDriveFile", "unmarkSensitiveDriveFile", "resolveAbuseReport", "createInvitation", "createAd", "updateAd", "deleteAd", "createAvatarDecoration", "updateAvatarDecoration", "deleteAvatarDecoration", "unsetUserAvatar", "unsetUserBanner"]; +>>>>>>> 0e2e4c353f6d2fd2cc650007ec2f6a876acde8f7 // @public (undocumented) type MuteCreateRequest = operations['mute___create']['requestBody']['content']['application/json']; @@ -2838,7 +2853,11 @@ type PartialRolePolicyOverride = Partial<{ }>; // @public (undocumented) +<<<<<<< HEAD export const permissions: readonly ["read:account", "write:account", "read:blocks", "write:blocks", "read:drive", "write:drive", "read:favorites", "write:favorites", "read:following", "write:following", "read:messaging", "write:messaging", "read:mutes", "write:mutes", "write:notes", "read:notifications", "write:notifications", "read:reactions", "write:reactions", "write:votes", "read:pages", "write:pages", "write:page-likes", "read:page-likes", "read:user-groups", "write:user-groups", "read:channels", "write:channels", "read:gallery", "write:gallery", "read:gallery-likes", "write:gallery-likes", "read:flash", "write:flash", "read:flash-likes", "write:flash-likes", "read:admin:abuse-user-reports", "write:admin:delete-account", "write:admin:delete-all-files-of-a-user", "read:admin:index-stats", "read:admin:table-stats", "read:admin:user-ips", "read:admin:meta", "write:admin:reset-password", "write:admin:resolve-abuse-user-report", "write:admin:send-email", "read:admin:server-info", "read:admin:show-moderation-log", "read:admin:show-user", "write:admin:suspend-user", "write:admin:unset-user-avatar", "write:admin:unset-user-banner", "write:admin:unsuspend-user", "write:admin:meta", "write:admin:user-note", "write:admin:roles", "read:admin:roles", "write:admin:relays", "read:admin:relays", "write:admin:invite-codes", "read:admin:invite-codes", "write:admin:announcements", "read:admin:announcements", "write:admin:avatar-decorations", "read:admin:avatar-decorations", "write:admin:federation", "write:admin:account", "read:admin:account", "write:admin:emoji", "read:admin:emoji", "write:admin:queue", "read:admin:queue", "write:admin:promo", "write:admin:drive", "read:admin:drive", "write:admin:ad", "read:admin:ad", "write:invite-codes", "read:invite-codes", "write:clip-favorite", "read:clip-favorite", "read:federation", "write:report-abuse"]; +======= +export const permissions: readonly ["read:account", "write:account", "read:blocks", "write:blocks", "read:drive", "write:drive", "read:favorites", "write:favorites", "read:following", "write:following", "read:messaging", "write:messaging", "read:mutes", "write:mutes", "write:notes", "read:notifications", "write:notifications", "read:reactions", "write:reactions", "write:votes", "read:pages", "write:pages", "write:page-likes", "read:page-likes", "read:user-groups", "write:user-groups", "read:channels", "write:channels", "read:gallery", "write:gallery", "read:gallery-likes", "write:gallery-likes", "read:flash", "write:flash", "read:flash-likes", "write:flash-likes", "read:admin:abuse-user-reports", "write:admin:delete-account", "write:admin:delete-all-files-of-a-user", "write:admin:approve-account", "read:admin:index-stats", "read:admin:table-stats", "read:admin:user-ips", "read:admin:meta", "write:admin:reset-password", "write:admin:resolve-abuse-user-report", "write:admin:send-email", "read:admin:server-info", "read:admin:show-moderation-log", "read:admin:show-user", "read:admin:show-users", "write:admin:suspend-user", "write:admin:unset-user-avatar", "write:admin:unset-user-banner", "write:admin:unsuspend-user", "write:admin:meta", "write:admin:user-note", "write:admin:roles", "read:admin:roles", "write:admin:relays", "read:admin:relays", "write:admin:invite-codes", "read:admin:invite-codes", "write:admin:announcements", "read:admin:announcements", "write:admin:avatar-decorations", "read:admin:avatar-decorations", "write:admin:federation", "write:admin:account", "read:admin:account", "write:admin:emoji", "read:admin:emoji", "write:admin:queue", "read:admin:queue", "write:admin:promo", "write:admin:drive", "read:admin:drive", "write:admin:ad", "read:admin:ad", "write:invite-codes", "read:invite-codes", "write:clip-favorite", "read:clip-favorite", "read:federation", "write:report-abuse"]; +>>>>>>> 0e2e4c353f6d2fd2cc650007ec2f6a876acde8f7 // @public (undocumented) type PingResponse = operations['ping']['responses']['200']['content']['application/json']; diff --git a/packages/misskey-js/src/autogen/apiClientJSDoc.ts b/packages/misskey-js/src/autogen/apiClientJSDoc.ts index 5ce823e01153..d5de9da30051 100644 --- a/packages/misskey-js/src/autogen/apiClientJSDoc.ts +++ b/packages/misskey-js/src/autogen/apiClientJSDoc.ts @@ -757,6 +757,17 @@ declare module '../api.js' { credential?: string | null, ): Promise>; + /** + * No description provided. + * + * **Credential required**: *Yes* / **Permission**: *write:admin:approve-account* + */ + request( + endpoint: E, + params: P, + credential?: string | null, + ): Promise>; + /** * No description provided. * diff --git a/packages/misskey-js/src/autogen/endpoint.ts b/packages/misskey-js/src/autogen/endpoint.ts index ae81483e6e38..483b8e14657a 100644 --- a/packages/misskey-js/src/autogen/endpoint.ts +++ b/packages/misskey-js/src/autogen/endpoint.ts @@ -92,6 +92,7 @@ import type { AdminShowUsersRequest, AdminShowUsersResponse, AdminSuspendUserRequest, + AdminApproveUserRequest, AdminUnsuspendUserRequest, AdminUpdateMetaRequest, AdminDeleteAccountRequest, @@ -645,6 +646,7 @@ export type Endpoints = { 'admin/show-user': { req: AdminShowUserRequest; res: AdminShowUserResponse }; 'admin/show-users': { req: AdminShowUsersRequest; res: AdminShowUsersResponse }; 'admin/suspend-user': { req: AdminSuspendUserRequest; res: EmptyResponse }; + 'admin/approve-user': { req: AdminApproveUserRequest; res: EmptyResponse }; 'admin/unsuspend-user': { req: AdminUnsuspendUserRequest; res: EmptyResponse }; 'admin/update-meta': { req: AdminUpdateMetaRequest; res: EmptyResponse }; 'admin/delete-account': { req: AdminDeleteAccountRequest; res: EmptyResponse }; diff --git a/packages/misskey-js/src/autogen/entities.ts b/packages/misskey-js/src/autogen/entities.ts index 7843382336ae..0da0c899e6fc 100644 --- a/packages/misskey-js/src/autogen/entities.ts +++ b/packages/misskey-js/src/autogen/entities.ts @@ -95,6 +95,7 @@ export type AdminShowUserResponse = operations['admin___show-user']['responses'] export type AdminShowUsersRequest = operations['admin___show-users']['requestBody']['content']['application/json']; export type AdminShowUsersResponse = operations['admin___show-users']['responses']['200']['content']['application/json']; export type AdminSuspendUserRequest = operations['admin___suspend-user']['requestBody']['content']['application/json']; +export type AdminApproveUserRequest = operations['admin__approve-user']['requestBody']['content']['application/json']; export type AdminUnsuspendUserRequest = operations['admin___unsuspend-user']['requestBody']['content']['application/json']; export type AdminUpdateMetaRequest = operations['admin___update-meta']['requestBody']['content']['application/json']; export type AdminDeleteAccountRequest = operations['admin___delete-account']['requestBody']['content']['application/json']; diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 7a45ab6755e3..8c5747bf5430 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -630,6 +630,15 @@ export type paths = { */ post: operations['admin___suspend-user']; }; + '/admin/approve-user': { + /** + * admin/approve-user + * @description No description provided. + * + * **Credential required**: *Yes* / **Permission**: *write:admin:approve-account* + */ + post: operations['admin/approve-user']; + }; '/admin/unsuspend-user': { /** * admin/unsuspend-user @@ -3801,6 +3810,7 @@ export type components = { followedMessage?: string | null; memo: string | null; moderationNote?: string; + approved?: boolean; isFollowing?: boolean; isFollowed?: boolean; hasPendingFollowRequestFromYou?: boolean; @@ -5086,6 +5096,7 @@ export type operations = { cacheRemoteFiles: boolean; cacheRemoteSensitiveFiles: boolean; emailRequiredForSignup: boolean; + approvalRequiredForSignup: boolean; enableHcaptcha: boolean; hcaptchaSiteKey: string | null; enableMcaptcha: boolean; @@ -9169,7 +9180,7 @@ export type operations = { * @default all * @enum {string} */ - state?: 'all' | 'alive' | 'available' | 'admin' | 'moderator' | 'adminOrModerator' | 'suspended'; + state?: 'all' | 'alive' | 'available' | 'admin' | 'moderator' | 'adminOrModerator' | 'suspended' | 'approved'; /** * @default combined * @enum {string} @@ -9276,6 +9287,58 @@ export type operations = { }; }; }; + /** + * admin/approve-user + * @description No description provided. + * + * **Credential required**: *Yes* / **Permission**: *write:admin:approve-account* + */ + 'admin__approve-user': { + requestBody: { + content: { + 'application/json': { + /** Format: misskey:id */ + userId: string; + }; + }; + }; + responses: { + /** @description OK (without any results) */ + 204: { + content: never; + }; + /** @description Client error */ + 400: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description Authentication error */ + 401: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description Forbidden error */ + 403: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description I'm Ai */ + 418: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description Internal server error */ + 500: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + }; + }; /** * admin/unsuspend-user * @description No description provided. @@ -9363,6 +9426,7 @@ export type operations = { cacheRemoteFiles?: boolean; cacheRemoteSensitiveFiles?: boolean; emailRequiredForSignup?: boolean; + approvalRequiredForSignup?: boolean; enableHcaptcha?: boolean; hcaptchaSiteKey?: string | null; hcaptchaSecretKey?: string | null; diff --git a/packages/misskey-js/src/consts.ts b/packages/misskey-js/src/consts.ts index b4fbcffa9774..7e19ca2d4962 100644 --- a/packages/misskey-js/src/consts.ts +++ b/packages/misskey-js/src/consts.ts @@ -66,6 +66,7 @@ export const permissions = [ 'read:admin:abuse-user-reports', 'write:admin:delete-account', 'write:admin:delete-all-files-of-a-user', + 'write:admin:approve-account', 'read:admin:index-stats', 'read:admin:table-stats', 'read:admin:user-ips', @@ -115,6 +116,7 @@ export const permissions = [ export const moderationLogTypes = [ 'updateServerSettings', 'suspend', + 'approve', 'unsuspend', 'updateUserNote', 'addCustomEmoji', @@ -193,6 +195,11 @@ export type ModerationLogPayloads = { userUsername: string; userHost: string | null; }; + approve: { + userId: string; + userUsername: string; + userHost: string | null; + }; unsuspend: { userId: string; userUsername: string; diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index 64ed90cbb119..bfba8b4a87ad 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -47,6 +47,9 @@ export type ModerationLog = { } & ({ type: 'updateServerSettings'; info: ModerationLogPayloads['updateServerSettings']; +} | { + type: 'approve'; + info: ModerationLogPayloads['approve']; } | { type: 'suspend'; info: ModerationLogPayloads['suspend']; From dbd302860b32d6eeb704d26097cca56cc7d274b9 Mon Sep 17 00:00:00 2001 From: HotoRas Date: Sat, 19 Oct 2024 19:55:27 +0900 Subject: [PATCH 02/22] Fixup stage 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JSON 수정 더 해야함 빡치네 --- packages/backend/src/core/SignupService.ts | 3 +++ .../backend/src/models/json-schema/meta.ts | 4 ++++ .../backend/src/server/api/ApiCallService.ts | 4 +--- .../src/server/api/SignupApiService.ts | 12 +++++----- .../api/endpoints/admin/approve-user.ts | 1 + .../src/components/MkApprovalUser.vue | 4 ++-- .../src/components/MkSignupDialog.form.vue | 2 +- .../src/components/MkSignupDialog.vue | 2 +- packages/frontend/src/pages/admin-user.vue | 20 ++++++++--------- packages/misskey-js/etc/misskey-js.api.md | 22 +++++-------------- .../misskey-js/src/autogen/apiClientJSDoc.ts | 1 + packages/misskey-js/src/autogen/entities.ts | 2 +- packages/misskey-js/src/autogen/types.ts | 8 +++++-- 13 files changed, 41 insertions(+), 44 deletions(-) diff --git a/packages/backend/src/core/SignupService.ts b/packages/backend/src/core/SignupService.ts index cc8a3d6461d5..b16753df630c 100644 --- a/packages/backend/src/core/SignupService.ts +++ b/packages/backend/src/core/SignupService.ts @@ -53,6 +53,7 @@ export class SignupService { passwordHash?: MiUserProfile['password'] | null; host?: string | null; ignorePreservedUsernames?: boolean; + reason?: string | null; }) { const { username, password, passwordHash, host } = opts; let hash = passwordHash; @@ -130,6 +131,8 @@ export class SignupService { host: this.utilityService.toPunyNullable(host), token: secret, isRoot: isTheFirstUser, + signupReason: opts.reason, + updatedAt: new Date(), })); await transactionalEntityManager.save(new MiUserKeypair({ diff --git a/packages/backend/src/models/json-schema/meta.ts b/packages/backend/src/models/json-schema/meta.ts index 99feeaa7d757..2203aca00150 100644 --- a/packages/backend/src/models/json-schema/meta.ts +++ b/packages/backend/src/models/json-schema/meta.ts @@ -79,6 +79,10 @@ export const packedMetaLiteSchema = { type: 'boolean', optional: false, nullable: false, }, + approvalRequiredForSignup: { + type: 'boolean', + optional: false, default: false, + }, enableHcaptcha: { type: 'boolean', optional: false, nullable: false, diff --git a/packages/backend/src/server/api/ApiCallService.ts b/packages/backend/src/server/api/ApiCallService.ts index 07d30d3e9bad..2484b354c116 100644 --- a/packages/backend/src/server/api/ApiCallService.ts +++ b/packages/backend/src/server/api/ApiCallService.ts @@ -342,8 +342,6 @@ export class ApiCallService implements OnApplicationShutdown { } } - const instance = await this.metaService.fetch(true); - if (ep.meta.requireCredential || ep.meta.requireModerator || ep.meta.requireAdmin) { if (user == null) { throw new ApiError({ @@ -359,7 +357,7 @@ export class ApiCallService implements OnApplicationShutdown { kind: 'permission', id: 'a8c724b3-6e9c-4b46-b1a8-bc3ed6258370', }); - } else if (instance.approvalRequiredForSignup && user!.approved === false) { + } else if (this.meta.approvalRequiredForSignup && user!.approved === false) { throw new ApiError({ message: 'Your account is not approved yet.', code: 'YOUR_ACCOUNT_NOT_APPROVED', diff --git a/packages/backend/src/server/api/SignupApiService.ts b/packages/backend/src/server/api/SignupApiService.ts index 91c322f7c4b6..5e90fd63020d 100644 --- a/packages/backend/src/server/api/SignupApiService.ts +++ b/packages/backend/src/server/api/SignupApiService.ts @@ -18,10 +18,10 @@ import { MiLocalUser } from '@/models/User.js'; import { FastifyReplyError } from '@/misc/fastify-reply-error.js'; import { bindThis } from '@/decorators.js'; import { L_CHARS, secureRndstr } from '@/misc/secure-rndstr.js'; +import { RoleService } from '@/core/RoleService.js'; import { SigninService } from './SigninService.js'; -import type { FastifyRequest, FastifyReply } from 'fastify'; import instance from './endpoints/charts/instance.js'; -import { RoleService } from '@/core/RoleService.js'; +import type { FastifyRequest, FastifyReply } from 'fastify'; @Injectable() export class SignupApiService { @@ -125,7 +125,7 @@ export class SignupApiService { } } - if (instance.approvalRequiredForSignup) { + if (this.meta.approvalRequiredForSignup) { if (reason == null || typeof reason !== 'string') { reply.code(400); return; @@ -218,7 +218,7 @@ export class SignupApiService { reply.code(204); return; - } else if (instance.approvalRequiredForSignup) { + } else if (this.meta.approvalRequiredForSignup) { const { account } = await this.signupService.signup({ username, password, host, reason, }); @@ -286,8 +286,6 @@ export class SignupApiService { const code = body['code']; - const instance = await this.metaService.fetch(true); - try { const pendingUser = await this.userPendingsRepository.findOneByOrFail({ code }); @@ -322,7 +320,7 @@ export class SignupApiService { }); } - if (instance.approvalRequiredForSignup) { + if (this.meta.approvalRequiredForSignup) { if (pendingUser.email) { this.emailService.sendEmail(pendingUser.email, 'Approval pending', 'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.', diff --git a/packages/backend/src/server/api/endpoints/admin/approve-user.ts b/packages/backend/src/server/api/endpoints/admin/approve-user.ts index 93e8a7e19529..09a90d47e7a9 100644 --- a/packages/backend/src/server/api/endpoints/admin/approve-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/approve-user.ts @@ -11,6 +11,7 @@ export const meta = { requireCredential: true, requireModerator: true, kind: 'write:admin:approve-account', + secure: true, } as const; export const paramDef = { diff --git a/packages/frontend/src/components/MkApprovalUser.vue b/packages/frontend/src/components/MkApprovalUser.vue index edc73c0848e1..b5d405161527 100644 --- a/packages/frontend/src/components/MkApprovalUser.vue +++ b/packages/frontend/src/components/MkApprovalUser.vue @@ -12,7 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.ts.createdAt }}
-
+
{{ i18n.ts.emailAddress }}
@@ -52,7 +52,7 @@ function getReason() { userId: props.user.id, }).then(info => { reason.value = info.signupReason; - email.value = info.email; + email.value = info.email ?? ''; }); } diff --git a/packages/frontend/src/components/MkSignupDialog.form.vue b/packages/frontend/src/components/MkSignupDialog.form.vue index bf4dfa1ba3d9..85652b3d57a0 100644 --- a/packages/frontend/src/components/MkSignupDialog.form.vue +++ b/packages/frontend/src/components/MkSignupDialog.form.vue @@ -85,10 +85,10 @@ SPDX-License-Identifier: AGPL-3.0-only import { ref, computed } from 'vue'; import { toUnicode } from 'punycode/'; import * as Misskey from 'misskey-js'; +import * as config from '@@/js/config.js'; import MkButton from './MkButton.vue'; import MkInput from './MkInput.vue'; import MkCaptcha, { type Captcha } from '@/components/MkCaptcha.vue'; -import * as config from '@@/js/config.js'; import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js'; import { login } from '@/account.js'; diff --git a/packages/frontend/src/components/MkSignupDialog.vue b/packages/frontend/src/components/MkSignupDialog.vue index 91e7d5dd5377..cd73e0fed997 100644 --- a/packages/frontend/src/components/MkSignupDialog.vue +++ b/packages/frontend/src/components/MkSignupDialog.vue @@ -65,7 +65,7 @@ function onSignupEmailPending() { } function onApprovalPending() { - dialog.value.close(); + dialog.value?.close(); } diff --git a/packages/frontend/src/pages/admin-user.vue b/packages/frontend/src/pages/admin-user.vue index e53cab5dac25..2d3b4026d7ca 100644 --- a/packages/frontend/src/pages/admin-user.vue +++ b/packages/frontend/src/pages/admin-user.vue @@ -283,7 +283,7 @@ function createFetcher() { moderationNote.value = info.value.moderationNote; watch(moderationNote, async () => { - await misskeyApi('admin/update-user-note', { userId: user.value.id, text: moderationNote.value }); + await misskeyApi('admin/update-user-note', { userId: user.value!.id, text: moderationNote.value }); await refreshUser(); }); }); @@ -294,7 +294,7 @@ function refreshUser() { } async function updateRemoteUser() { - await os.apiWithDialog('federation/update-remote-user', { userId: user.value.id }); + await os.apiWithDialog('federation/update-remote-user', { userId: user.value!.id }); refreshUser(); } @@ -307,7 +307,7 @@ async function resetPassword() { return; } else { const { password } = await misskeyApi('admin/reset-password', { - userId: user.value.id, + userId: user.value!.id, }); os.alert({ type: 'success', @@ -324,7 +324,7 @@ async function toggleSuspend(v) { if (confirm.canceled) { suspended.value = !v; } else { - await misskeyApi(v ? 'admin/suspend-user' : 'admin/unsuspend-user', { userId: user.value.id }); + await misskeyApi(v ? 'admin/suspend-user' : 'admin/unsuspend-user', { userId: user.value!.id }); await refreshUser(); } } @@ -336,7 +336,7 @@ async function unsetUserAvatar() { }); if (confirm.canceled) return; const process = async () => { - await misskeyApi('admin/unset-user-avatar', { userId: user.value.id }); + await misskeyApi('admin/unset-user-avatar', { userId: user.value!.id }); os.success(); }; await process().catch(err => { @@ -355,7 +355,7 @@ async function unsetUserBanner() { }); if (confirm.canceled) return; const process = async () => { - await misskeyApi('admin/unset-user-banner', { userId: user.value.id }); + await misskeyApi('admin/unset-user-banner', { userId: user.value!.id }); os.success(); }; await process().catch(err => { @@ -374,7 +374,7 @@ async function deleteAllFiles() { }); if (confirm.canceled) return; const process = async () => { - await misskeyApi('admin/delete-all-files-of-a-user', { userId: user.value.id }); + await misskeyApi('admin/delete-all-files-of-a-user', { userId: user.value!.id }); os.success(); }; await process().catch(err => { @@ -443,7 +443,7 @@ async function assignRole() { : period === 'oneMonth' ? Date.now() + (1000 * 60 * 60 * 24 * 30) : null; - await os.apiWithDialog('admin/roles/assign', { roleId, userId: user.value.id, expiresAt }); + await os.apiWithDialog('admin/roles/assign', { roleId, userId: user.value!.id, expiresAt }); refreshUser(); } @@ -453,7 +453,7 @@ async function unassignRole(role, ev) { icon: 'ti ti-x', danger: true, action: async () => { - await os.apiWithDialog('admin/roles/unassign', { roleId: role.id, userId: user.value.id }); + await os.apiWithDialog('admin/roles/unassign', { roleId: role.id, userId: user.value!.id }); refreshUser(); }, }], ev.currentTarget ?? ev.target); @@ -492,7 +492,7 @@ watch(() => props.userId, () => { watch(user, () => { misskeyApi('ap/get', { - uri: user.value.uri ?? `${url}/users/${user.value.id}`, + uri: user.value?.uri ?? `${url}/users/${user.value!.id}`, }).then(res => { ap.value = res; }); diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index 3bc49daa2f97..faec0a63fa25 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -89,14 +89,7 @@ type AdminAdCreateResponse = operations['admin___ad___create']['responses']['200 type AdminAdDeleteRequest = operations['admin___ad___delete']['requestBody']['content']['application/json']; // @public (undocumented) -<<<<<<< HEAD type AdminAdListRequest = operations['admin___ad___list']['requestBody']['content']['application/json']; -======= -type AdminApproveUserRequest = operations['admin/approve-user']['requestBody']['content']['application/json']; - -// @public (undocumented) -type AdminAvatarDecorationsCreateRequest = operations['admin/avatar-decorations/create']['requestBody']['content']['application/json']; ->>>>>>> 0e2e4c353f6d2fd2cc650007ec2f6a876acde8f7 // @public (undocumented) type AdminAdListResponse = operations['admin___ad___list']['responses']['200']['content']['application/json']; @@ -122,6 +115,9 @@ type AdminAnnouncementsListResponse = operations['admin___announcements___list'] // @public (undocumented) type AdminAnnouncementsUpdateRequest = operations['admin___announcements___update']['requestBody']['content']['application/json']; +// @public (undocumented) +type AdminApproveUserRequest = operations['admin___approve-user']['requestBody']['content']['application/json']; + // @public (undocumented) type AdminAvatarDecorationsCreateRequest = operations['admin___avatar-decorations___create']['requestBody']['content']['application/json']; @@ -2578,11 +2574,7 @@ type ModerationLog = { }); // @public (undocumented) -<<<<<<< HEAD -export const moderationLogTypes: readonly ["updateServerSettings", "suspend", "unsuspend", "updateUserNote", "addCustomEmoji", "updateCustomEmoji", "deleteCustomEmoji", "assignRole", "unassignRole", "createRole", "updateRole", "deleteRole", "clearQueue", "promoteQueue", "deleteDriveFile", "deleteNote", "createGlobalAnnouncement", "createUserAnnouncement", "updateGlobalAnnouncement", "updateUserAnnouncement", "deleteGlobalAnnouncement", "deleteUserAnnouncement", "resetPassword", "suspendRemoteInstance", "unsuspendRemoteInstance", "updateRemoteInstanceNote", "markSensitiveDriveFile", "unmarkSensitiveDriveFile", "resolveAbuseReport", "createInvitation", "createAd", "updateAd", "deleteAd", "createAvatarDecoration", "updateAvatarDecoration", "deleteAvatarDecoration", "unsetUserAvatar", "unsetUserBanner", "createSystemWebhook", "updateSystemWebhook", "deleteSystemWebhook", "createAbuseReportNotificationRecipient", "updateAbuseReportNotificationRecipient", "deleteAbuseReportNotificationRecipient", "deleteAccount", "deletePage", "deleteFlash", "deleteGalleryPost"]; -======= -export const moderationLogTypes: readonly ["updateServerSettings", "suspend", "approve", "unsuspend", "updateUserNote", "addCustomEmoji", "updateCustomEmoji", "deleteCustomEmoji", "assignRole", "unassignRole", "createRole", "updateRole", "deleteRole", "clearQueue", "promoteQueue", "deleteDriveFile", "deleteNote", "createGlobalAnnouncement", "createUserAnnouncement", "updateGlobalAnnouncement", "updateUserAnnouncement", "deleteGlobalAnnouncement", "deleteUserAnnouncement", "resetPassword", "suspendRemoteInstance", "unsuspendRemoteInstance", "markSensitiveDriveFile", "unmarkSensitiveDriveFile", "resolveAbuseReport", "createInvitation", "createAd", "updateAd", "deleteAd", "createAvatarDecoration", "updateAvatarDecoration", "deleteAvatarDecoration", "unsetUserAvatar", "unsetUserBanner"]; ->>>>>>> 0e2e4c353f6d2fd2cc650007ec2f6a876acde8f7 +export const moderationLogTypes: readonly ["updateServerSettings", "suspend", "approve", "unsuspend", "updateUserNote", "addCustomEmoji", "updateCustomEmoji", "deleteCustomEmoji", "assignRole", "unassignRole", "createRole", "updateRole", "deleteRole", "clearQueue", "promoteQueue", "deleteDriveFile", "deleteNote", "createGlobalAnnouncement", "createUserAnnouncement", "updateGlobalAnnouncement", "updateUserAnnouncement", "deleteGlobalAnnouncement", "deleteUserAnnouncement", "resetPassword", "suspendRemoteInstance", "unsuspendRemoteInstance", "updateRemoteInstanceNote", "markSensitiveDriveFile", "unmarkSensitiveDriveFile", "resolveAbuseReport", "createInvitation", "createAd", "updateAd", "deleteAd", "createAvatarDecoration", "updateAvatarDecoration", "deleteAvatarDecoration", "unsetUserAvatar", "unsetUserBanner", "createSystemWebhook", "updateSystemWebhook", "deleteSystemWebhook", "createAbuseReportNotificationRecipient", "updateAbuseReportNotificationRecipient", "deleteAbuseReportNotificationRecipient", "deleteAccount", "deletePage", "deleteFlash", "deleteGalleryPost"]; // @public (undocumented) type MuteCreateRequest = operations['mute___create']['requestBody']['content']['application/json']; @@ -2853,11 +2845,7 @@ type PartialRolePolicyOverride = Partial<{ }>; // @public (undocumented) -<<<<<<< HEAD -export const permissions: readonly ["read:account", "write:account", "read:blocks", "write:blocks", "read:drive", "write:drive", "read:favorites", "write:favorites", "read:following", "write:following", "read:messaging", "write:messaging", "read:mutes", "write:mutes", "write:notes", "read:notifications", "write:notifications", "read:reactions", "write:reactions", "write:votes", "read:pages", "write:pages", "write:page-likes", "read:page-likes", "read:user-groups", "write:user-groups", "read:channels", "write:channels", "read:gallery", "write:gallery", "read:gallery-likes", "write:gallery-likes", "read:flash", "write:flash", "read:flash-likes", "write:flash-likes", "read:admin:abuse-user-reports", "write:admin:delete-account", "write:admin:delete-all-files-of-a-user", "read:admin:index-stats", "read:admin:table-stats", "read:admin:user-ips", "read:admin:meta", "write:admin:reset-password", "write:admin:resolve-abuse-user-report", "write:admin:send-email", "read:admin:server-info", "read:admin:show-moderation-log", "read:admin:show-user", "write:admin:suspend-user", "write:admin:unset-user-avatar", "write:admin:unset-user-banner", "write:admin:unsuspend-user", "write:admin:meta", "write:admin:user-note", "write:admin:roles", "read:admin:roles", "write:admin:relays", "read:admin:relays", "write:admin:invite-codes", "read:admin:invite-codes", "write:admin:announcements", "read:admin:announcements", "write:admin:avatar-decorations", "read:admin:avatar-decorations", "write:admin:federation", "write:admin:account", "read:admin:account", "write:admin:emoji", "read:admin:emoji", "write:admin:queue", "read:admin:queue", "write:admin:promo", "write:admin:drive", "read:admin:drive", "write:admin:ad", "read:admin:ad", "write:invite-codes", "read:invite-codes", "write:clip-favorite", "read:clip-favorite", "read:federation", "write:report-abuse"]; -======= -export const permissions: readonly ["read:account", "write:account", "read:blocks", "write:blocks", "read:drive", "write:drive", "read:favorites", "write:favorites", "read:following", "write:following", "read:messaging", "write:messaging", "read:mutes", "write:mutes", "write:notes", "read:notifications", "write:notifications", "read:reactions", "write:reactions", "write:votes", "read:pages", "write:pages", "write:page-likes", "read:page-likes", "read:user-groups", "write:user-groups", "read:channels", "write:channels", "read:gallery", "write:gallery", "read:gallery-likes", "write:gallery-likes", "read:flash", "write:flash", "read:flash-likes", "write:flash-likes", "read:admin:abuse-user-reports", "write:admin:delete-account", "write:admin:delete-all-files-of-a-user", "write:admin:approve-account", "read:admin:index-stats", "read:admin:table-stats", "read:admin:user-ips", "read:admin:meta", "write:admin:reset-password", "write:admin:resolve-abuse-user-report", "write:admin:send-email", "read:admin:server-info", "read:admin:show-moderation-log", "read:admin:show-user", "read:admin:show-users", "write:admin:suspend-user", "write:admin:unset-user-avatar", "write:admin:unset-user-banner", "write:admin:unsuspend-user", "write:admin:meta", "write:admin:user-note", "write:admin:roles", "read:admin:roles", "write:admin:relays", "read:admin:relays", "write:admin:invite-codes", "read:admin:invite-codes", "write:admin:announcements", "read:admin:announcements", "write:admin:avatar-decorations", "read:admin:avatar-decorations", "write:admin:federation", "write:admin:account", "read:admin:account", "write:admin:emoji", "read:admin:emoji", "write:admin:queue", "read:admin:queue", "write:admin:promo", "write:admin:drive", "read:admin:drive", "write:admin:ad", "read:admin:ad", "write:invite-codes", "read:invite-codes", "write:clip-favorite", "read:clip-favorite", "read:federation", "write:report-abuse"]; ->>>>>>> 0e2e4c353f6d2fd2cc650007ec2f6a876acde8f7 +export const permissions: readonly ["read:account", "write:account", "read:blocks", "write:blocks", "read:drive", "write:drive", "read:favorites", "write:favorites", "read:following", "write:following", "read:messaging", "write:messaging", "read:mutes", "write:mutes", "write:notes", "read:notifications", "write:notifications", "read:reactions", "write:reactions", "write:votes", "read:pages", "write:pages", "write:page-likes", "read:page-likes", "read:user-groups", "write:user-groups", "read:channels", "write:channels", "read:gallery", "write:gallery", "read:gallery-likes", "write:gallery-likes", "read:flash", "write:flash", "read:flash-likes", "write:flash-likes", "read:admin:abuse-user-reports", "write:admin:delete-account", "write:admin:delete-all-files-of-a-user", "write:admin:approve-account", "read:admin:index-stats", "read:admin:table-stats", "read:admin:user-ips", "read:admin:meta", "write:admin:reset-password", "write:admin:resolve-abuse-user-report", "write:admin:send-email", "read:admin:server-info", "read:admin:show-moderation-log", "read:admin:show-user", "write:admin:suspend-user", "write:admin:unset-user-avatar", "write:admin:unset-user-banner", "write:admin:unsuspend-user", "write:admin:meta", "write:admin:user-note", "write:admin:roles", "read:admin:roles", "write:admin:relays", "read:admin:relays", "write:admin:invite-codes", "read:admin:invite-codes", "write:admin:announcements", "read:admin:announcements", "write:admin:avatar-decorations", "read:admin:avatar-decorations", "write:admin:federation", "write:admin:account", "read:admin:account", "write:admin:emoji", "read:admin:emoji", "write:admin:queue", "read:admin:queue", "write:admin:promo", "write:admin:drive", "read:admin:drive", "write:admin:ad", "read:admin:ad", "write:invite-codes", "read:invite-codes", "write:clip-favorite", "read:clip-favorite", "read:federation", "write:report-abuse"]; // @public (undocumented) type PingResponse = operations['ping']['responses']['200']['content']['application/json']; diff --git a/packages/misskey-js/src/autogen/apiClientJSDoc.ts b/packages/misskey-js/src/autogen/apiClientJSDoc.ts index d5de9da30051..9bf4528bb7b7 100644 --- a/packages/misskey-js/src/autogen/apiClientJSDoc.ts +++ b/packages/misskey-js/src/autogen/apiClientJSDoc.ts @@ -760,6 +760,7 @@ declare module '../api.js' { /** * No description provided. * + * **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties. * **Credential required**: *Yes* / **Permission**: *write:admin:approve-account* */ request( diff --git a/packages/misskey-js/src/autogen/entities.ts b/packages/misskey-js/src/autogen/entities.ts index 0da0c899e6fc..50d881ad3013 100644 --- a/packages/misskey-js/src/autogen/entities.ts +++ b/packages/misskey-js/src/autogen/entities.ts @@ -95,7 +95,7 @@ export type AdminShowUserResponse = operations['admin___show-user']['responses'] export type AdminShowUsersRequest = operations['admin___show-users']['requestBody']['content']['application/json']; export type AdminShowUsersResponse = operations['admin___show-users']['responses']['200']['content']['application/json']; export type AdminSuspendUserRequest = operations['admin___suspend-user']['requestBody']['content']['application/json']; -export type AdminApproveUserRequest = operations['admin__approve-user']['requestBody']['content']['application/json']; +export type AdminApproveUserRequest = operations['admin___approve-user']['requestBody']['content']['application/json']; export type AdminUnsuspendUserRequest = operations['admin___unsuspend-user']['requestBody']['content']['application/json']; export type AdminUpdateMetaRequest = operations['admin___update-meta']['requestBody']['content']['application/json']; export type AdminDeleteAccountRequest = operations['admin___delete-account']['requestBody']['content']['application/json']; diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 8c5747bf5430..5a5202d62739 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -635,9 +635,10 @@ export type paths = { * admin/approve-user * @description No description provided. * + * **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties. * **Credential required**: *Yes* / **Permission**: *write:admin:approve-account* */ - post: operations['admin/approve-user']; + post: operations['admin___approve-user']; }; '/admin/unsuspend-user': { /** @@ -4966,6 +4967,8 @@ export type components = { defaultLightTheme: string | null; disableRegistration: boolean; emailRequiredForSignup: boolean; + /** @default false */ + approvalRequiredForSignup: boolean; enableHcaptcha: boolean; hcaptchaSiteKey: string | null; enableMcaptcha: boolean; @@ -9291,9 +9294,10 @@ export type operations = { * admin/approve-user * @description No description provided. * + * **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties. * **Credential required**: *Yes* / **Permission**: *write:admin:approve-account* */ - 'admin__approve-user': { + 'admin___approve-user': { requestBody: { content: { 'application/json': { From effcdaaebfb5cc1fda97f1160ae12f18bcdcb9df Mon Sep 17 00:00:00 2001 From: HotoRas Date: Sun, 20 Oct 2024 13:22:56 +0900 Subject: [PATCH 03/22] Fixup stage 2 [Ready to first check] --- Changelog-neko.md | 6 +-- .../activitypub/models/ApPersonService.ts | 43 +++++++++---------- .../backend/src/models/json-schema/user.ts | 5 +++ packages/frontend/.storybook/fakes.ts | 1 + packages/frontend/src/components/MkSignin.vue | 2 +- .../src/components/MkVisitorDashboard.vue | 4 +- packages/frontend/src/pages/admin-user.vue | 2 +- .../frontend/src/pages/admin/approvals.vue | 2 +- packages/frontend/src/pages/admin/users.vue | 2 +- packages/misskey-js/src/autogen/types.ts | 5 +++ 10 files changed, 41 insertions(+), 31 deletions(-) diff --git a/Changelog-neko.md b/Changelog-neko.md index abc6706dd057..ff86686e2433 100644 --- a/Changelog-neko.md +++ b/Changelog-neko.md @@ -1,8 +1,8 @@ -## Unreleased +## Unreleased (2024.9.0+neko.rc-2) ### General -- Feat: ユーザー登録を承認制にできるように (cherry-pick from https://git.joinsharkey.org/Sharkey/Sharkey) -- Fix: リストライムラインの「リノートを表示」が正しく機能しない問題を修正 +- Feat: 사용자 등록을 승인제로 할 수 있도록 +(pull from 0e2e4c353f6d2fd2cc650007ec2f6a876acde8f7) ### Frontend diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index 502a13d2db54..13e6ac3c8cf4 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -38,7 +38,8 @@ import { RoleService } from '@/core/RoleService.js'; import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js'; import type { AccountMoveService } from '@/core/AccountMoveService.js'; import { checkHttps } from '@/misc/check-https.js'; -import { getApId, getApType, getOneApHrefNullable, isActor, isCollection, isCollectionOrOrderedCollection, isPropertyValue } from '../type.js'; +import { AvatarDecorationService } from '@/core/AvatarDecorationService.js'; +import * as APTypes from '../type.js'; import { extractApHashtags } from './tag.js'; import type { OnModuleInit } from '@nestjs/common'; import type { ApNoteService } from './ApNoteService.js'; @@ -47,8 +48,6 @@ import type { ApResolverService, Resolver } from '../ApResolverService.js'; import type { ApLoggerService } from '../ApLoggerService.js'; import type { ApImageService } from './ApImageService.js'; -import type { IActor, ICollection, IObject, IOrderedCollection } from '../type.js'; -import { AvatarDecorationService } from '@/core/AvatarDecorationService.js'; const nameLength = 128; const summaryLength = 2048; @@ -144,10 +143,10 @@ export class ApPersonService implements OnModuleInit { * @param uri Fetch target URI */ @bindThis - private validateActor(x: IObject, uri: string): IActor { + private validateActor(x: APTypes.IObject, uri: string): APTypes.IActor { const expectHost = this.punyHost(uri); - if (!isActor(x)) { + if (!APTypes.isActor(x)) { throw new Error(`invalid Actor type '${x.type}'`); } @@ -297,7 +296,7 @@ export class ApPersonService implements OnModuleInit { const tags = extractApHashtags(person.tag).map(normalizeForSearch).splice(0, 32); - const isBot = getApType(object) === 'Service' || getApType(object) === 'Application'; + const isBot = APTypes.getApType(object) === 'Service' || APTypes.getApType(object) === 'Application'; const [followingVisibility, followersVisibility] = await Promise.all( [ @@ -316,7 +315,7 @@ export class ApPersonService implements OnModuleInit { const bday = person['vcard:bday']?.match(/^\d{4}-\d{2}-\d{2}/); - const url = getOneApHrefNullable(person.url); + const url = APTypes.getOneApHrefNullable(person.url); if (url && !checkHttps(url)) { throw new Error('unexpected schema of person url: ' + url); @@ -354,12 +353,12 @@ export class ApPersonService implements OnModuleInit { host, inbox: person.inbox, sharedInbox: person.sharedInbox ?? person.endpoints?.sharedInbox, - followersUri: person.followers ? getApId(person.followers) : undefined, - featured: person.featured ? getApId(person.featured) : undefined, + followersUri: person.followers ? APTypes.getApId(person.followers) : undefined, + featured: person.featured ? APTypes.getApId(person.featured) : undefined, uri: person.id, tags, isBot, - isCat: (person as any).isCat === true, + isCat: (person as Partial).isCat === true, emojis, })) as MiRemoteUser; @@ -456,7 +455,7 @@ export class ApPersonService implements OnModuleInit { * @param movePreventUris ここに指定されたURIがPersonのmovedToに指定されていたり10回より多く回っている場合これ以上アカウント移行を行わない(無限ループ防止) */ @bindThis - public async updatePerson(uri: string, resolver?: Resolver | null, hint?: IObject, movePreventUris: string[] = []): Promise { + public async updatePerson(uri: string, resolver?: Resolver | null, hint?: APTypes.IObject, movePreventUris: string[] = []): Promise { if (typeof uri !== 'string') throw new Error('uri is not string'); // URIがこのサーバーを指しているならスキップ @@ -507,7 +506,7 @@ export class ApPersonService implements OnModuleInit { const bday = person['vcard:bday']?.match(/^\d{4}-\d{2}-\d{2}/); - const url = getOneApHrefNullable(person.url); + const url = APTypes.getOneApHrefNullable(person.url); if (url && !checkHttps(url)) { throw new Error('unexpected schema of person url: ' + url); @@ -517,14 +516,14 @@ export class ApPersonService implements OnModuleInit { lastFetchedAt: new Date(), inbox: person.inbox, sharedInbox: person.sharedInbox ?? person.endpoints?.sharedInbox, - followersUri: person.followers ? getApId(person.followers) : undefined, + followersUri: person.followers ? APTypes.getApId(person.followers) : undefined, featured: person.featured, emojis: emojiNames, name: truncate(person.name, nameLength), tags, approved: true, - isBot: getApType(object) === 'Service' || getApType(object) === 'Application', - isCat: (person as any).isCat === true, + isBot: APTypes.getApType(object) === 'Service' || APTypes.getApType(object) === 'Application', + isCat: (person as Partial).isCat === true, isLocked: person.manuallyApprovesFollowers, movedToUri: person.movedTo ?? null, alsoKnownAs: person.alsoKnownAs ?? null, @@ -643,11 +642,11 @@ export class ApPersonService implements OnModuleInit { @bindThis // TODO: `attachments`が`IObject`だった場合、返り値が`[]`になるようだが構わないのか? - public analyzeAttachments(attachments: IObject | IObject[] | undefined): Field[] { + public analyzeAttachments(attachments: APTypes.IObject | APTypes.IObject[] | undefined): Field[] { const fields: Field[] = []; if (Array.isArray(attachments)) { - for (const attachment of attachments.filter(isPropertyValue)) { + for (const attachment of attachments.filter(APTypes.isPropertyValue)) { fields.push({ name: attachment.name, value: this.mfmService.fromHtml(attachment.value), @@ -670,16 +669,16 @@ export class ApPersonService implements OnModuleInit { // Resolve to (Ordered)Collection Object const collection = await _resolver.resolveCollection(user.featured); - if (!isCollectionOrOrderedCollection(collection)) throw new Error('Object is not Collection or OrderedCollection'); + if (!APTypes.isCollectionOrOrderedCollection(collection)) throw new Error('Object is not Collection or OrderedCollection'); // Resolve to Object(may be Note) arrays - const unresolvedItems = isCollection(collection) ? collection.items : collection.orderedItems; + const unresolvedItems = APTypes.isCollection(collection) ? collection.items : collection.orderedItems; const items = await Promise.all(toArray(unresolvedItems).map(x => _resolver.resolve(x))); // Resolve and regist Notes const limit = promiseLimit(2); const featuredNotes = await Promise.all(items - .filter(item => getApType(item) === 'Note') // TODO: Noteでなくてもいいかも + .filter(item => APTypes.getApType(item) === 'Note') // TODO: Noteでなくてもいいかも .slice(0, 5) .map(item => limit(() => this.apNoteService.resolveNote(item, { resolver: _resolver, @@ -752,10 +751,10 @@ export class ApPersonService implements OnModuleInit { } @bindThis - private async isPublicCollection(collection: string | ICollection | IOrderedCollection | undefined, resolver: Resolver): Promise { + private async isPublicCollection(collection: string | APTypes.ICollection | APTypes.IOrderedCollection | undefined, resolver: Resolver): Promise { if (collection) { const resolved = await resolver.resolveCollection(collection); - if (resolved.first || (resolved as ICollection).items || (resolved as IOrderedCollection).orderedItems) { + if (resolved.first || (resolved as APTypes.ICollection).items || (resolved as APTypes.IOrderedCollection).orderedItems) { return true; } } diff --git a/packages/backend/src/models/json-schema/user.ts b/packages/backend/src/models/json-schema/user.ts index f925f0ddc088..3c2a38f8162b 100644 --- a/packages/backend/src/models/json-schema/user.ts +++ b/packages/backend/src/models/json-schema/user.ts @@ -62,6 +62,11 @@ export const packedUserLiteSchema = { example: 'misskey.example.com', description: 'The local host is represented with `null`.', }, + approved: { + type: 'boolean', + nullable: false, default: false, + description: 'User whom registeration is approved or not', + }, avatarUrl: { type: 'string', format: 'url', diff --git a/packages/frontend/.storybook/fakes.ts b/packages/frontend/.storybook/fakes.ts index 3bea50bf00f6..c3e21f36bc7c 100644 --- a/packages/frontend/.storybook/fakes.ts +++ b/packages/frontend/.storybook/fakes.ts @@ -184,6 +184,7 @@ export function federationInstance(): entities.FederationInstance { themeColor: '', infoUpdatedAt: '', latestRequestReceivedAt: '', + isMediaSilenced: false, }; } diff --git a/packages/frontend/src/components/MkSignin.vue b/packages/frontend/src/components/MkSignin.vue index 761f4189fb92..948229614b6a 100644 --- a/packages/frontend/src/components/MkSignin.vue +++ b/packages/frontend/src/components/MkSignin.vue @@ -235,7 +235,7 @@ function onSubmit(): void { } } -function loginFailed(err: any): void { +function loginFailed(err: Misskey.entities.Error): void { switch (err.id) { case '6cc579cc-885d-43d8-95c2-b8c7fc963280': { os.alert({ diff --git a/packages/frontend/src/components/MkVisitorDashboard.vue b/packages/frontend/src/components/MkVisitorDashboard.vue index 7100c0a979bb..74cc93fa0553 100644 --- a/packages/frontend/src/components/MkVisitorDashboard.vue +++ b/packages/frontend/src/components/MkVisitorDashboard.vue @@ -56,12 +56,13 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -37,7 +37,7 @@ const bgCss = bg.toRgbString(); display: inline-block; padding: 4px 8px 4px 4px; border-radius: 999px; - color: var(--mention); + color: var(--MI_THEME-mention); } .host { diff --git a/packages/frontend-embed/src/components/EmMfm.ts b/packages/frontend-embed/src/components/EmMfm.ts index b2bcf4597e35..cae2feb8fb28 100644 --- a/packages/frontend-embed/src/components/EmMfm.ts +++ b/packages/frontend-embed/src/components/EmMfm.ts @@ -6,6 +6,7 @@ import { VNode, h, SetupContext, provide } from 'vue'; import * as mfm from 'mfm-js'; import * as Misskey from 'misskey-js'; +import { host } from '@@/js/config.js'; import EmUrl from '@/components/EmUrl.vue'; import EmTime from '@/components/EmTime.vue'; import EmLink from '@/components/EmLink.vue'; @@ -13,7 +14,6 @@ import EmMention from '@/components/EmMention.vue'; import EmEmoji from '@/components/EmEmoji.vue'; import EmCustomEmoji from '@/components/EmCustomEmoji.vue'; import EmA from '@/components/EmA.vue'; -import { host } from '@@/js/config.js'; function safeParseFloat(str: unknown): number | null { if (typeof str !== 'string' || str === '') return null; @@ -26,8 +26,8 @@ const QUOTE_STYLE = ` display: block; margin: 8px; padding: 6px 0 6px 12px; -color: var(--fg); -border-left: solid 3px var(--fg); +color: var(--MI_THEME-fg); +border-left: solid 3px var(--MI_THEME-fg); opacity: 0.7; `.split('\n').join(' '); @@ -41,9 +41,6 @@ type MfmProps = { rootScale?: number; nyaize?: boolean | 'respect'; parsedNodes?: mfm.MfmNode[] | null; - enableEmojiMenu?: boolean; - enableEmojiMenuReaction?: boolean; - linkNavigationBehavior?: string; }; type MfmEvents = { @@ -52,8 +49,6 @@ type MfmEvents = { // eslint-disable-next-line import/no-default-export export default function (props: MfmProps, { emit }: { emit: SetupContext['emit'] }) { - provide('linkNavigationBehavior', props.linkNavigationBehavior); - const isNote = props.isNote ?? true; const shouldNyaize = props.nyaize ? props.nyaize === 'respect' ? props.author?.isCat : false : false; @@ -256,7 +251,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext= 2.5, - menu: props.enableEmojiMenu, - menuReaction: props.enableEmojiMenuReaction, fallbackToImage: false, })]; } else { diff --git a/packages/frontend-embed/src/components/EmNote.vue b/packages/frontend-embed/src/components/EmNote.vue index f7899bfb0336..f5b064c29330 100644 --- a/packages/frontend-embed/src/components/EmNote.vue +++ b/packages/frontend-embed/src/components/EmNote.vue @@ -108,6 +108,8 @@ SPDX-License-Identifier: AGPL-3.0-only import { computed, inject, ref, shallowRef } from 'vue'; import * as mfm from 'mfm-js'; import * as Misskey from 'misskey-js'; +import { shouldCollapsed } from '@@/js/collapsed.js'; +import { url } from '@@/js/config.js'; import I18n from '@/components/I18n.vue'; import EmNoteSub from '@/components/EmNoteSub.vue'; import EmNoteHeader from '@/components/EmNoteHeader.vue'; @@ -123,8 +125,6 @@ import EmUserName from '@/components/EmUserName.vue'; import EmTime from '@/components/EmTime.vue'; import { userPage } from '@/utils.js'; import { i18n } from '@/i18n.js'; -import { shouldCollapsed } from '@@/js/collapsed.js'; -import { url } from '@@/js/config.js'; function getAppearNote(note: Misskey.entities.Note) { return Misskey.note.isPureRenote(note) ? note.renote : note; @@ -164,14 +164,8 @@ const isDeleted = ref(false); font-size: 1.05em; overflow: clip; contain: content; - - // これらの指定はパフォーマンス向上には有効だが、ノートの高さは一定でないため、 - // 下の方までスクロールすると上のノートの高さがここで決め打ちされたものに変化し、表示しているノートの位置が変わってしまう - // ノートがマウントされたときに自身の高さを取得し contain-intrinsic-size を設定しなおせばほぼ解決できそうだが、 - // 今度はその処理自体がパフォーマンス低下の原因にならないか懸念される。また、被リアクションでも高さは変化するため、やはり多少のズレは生じる - // 一度レンダリングされた要素はブラウザがよしなにサイズを覚えておいてくれるような実装になるまで待った方が良さそう(なるのか?) - //content-visibility: auto; - //contain-intrinsic-size: 0 128px; + content-visibility: auto; + contain-intrinsic-size: 0 150px; &:focus-visible { outline: none; @@ -189,8 +183,8 @@ const isDeleted = ref(false); margin: auto; width: calc(100% - 8px); height: calc(100% - 8px); - border: dashed 2px var(--focus); - border-radius: var(--radius); + border: dashed 2px var(--MI_THEME-focus); + border-radius: var(--MI-radius); box-sizing: border-box; } } @@ -212,9 +206,9 @@ const isDeleted = ref(false); right: 12px; padding: 0 4px; margin-bottom: 0 !important; - background: var(--popup); + background: var(--MI_THEME-popup); border-radius: 8px; - box-shadow: 0px 4px 32px var(--shadow); + box-shadow: 0px 4px 32px var(--MI_THEME-shadow); } .footerButton { @@ -259,7 +253,7 @@ const isDeleted = ref(false); padding: 16px 32px 8px 32px; line-height: 28px; white-space: pre; - color: var(--renote); + color: var(--MI_THEME-renote); & + .article { padding-top: 8px; @@ -356,7 +350,7 @@ const isDeleted = ref(false); width: 58px; height: 58px; position: sticky !important; - top: calc(22px + var(--stickyTop, 0px)); + top: calc(22px + var(--MI-stickyTop, 0px)); left: 0; } @@ -377,12 +371,12 @@ const isDeleted = ref(false); width: 100%; margin-top: 14px; position: sticky; - bottom: calc(var(--stickyBottom, 0px) + 14px); + bottom: calc(var(--MI-stickyBottom, 0px) + 14px); } .showLessLabel { display: inline-block; - background: var(--popup); + background: var(--MI_THEME-popup); padding: 6px 10px; font-size: 0.8em; border-radius: 999px; @@ -403,16 +397,16 @@ const isDeleted = ref(false); z-index: 2; width: 100%; height: 64px; - background: linear-gradient(0deg, var(--panel), color(from var(--panel) srgb r g b / 0)); + background: linear-gradient(0deg, var(--MI_THEME-panel), color(from var(--MI_THEME-panel) srgb r g b / 0)); &:hover > .collapsedLabel { - background: var(--panelHighlight); + background: var(--MI_THEME-panelHighlight); } } .collapsedLabel { display: inline-block; - background: var(--panel); + background: var(--MI_THEME-panel); padding: 6px 10px; font-size: 0.8em; border-radius: 999px; @@ -424,13 +418,13 @@ const isDeleted = ref(false); } .replyIcon { - color: var(--accent); + color: var(--MI_THEME-accent); margin-right: 0.5em; } .translation { - border: solid 0.5px var(--divider); - border-radius: var(--radius); + border: solid 0.5px var(--MI_THEME-divider); + border-radius: var(--MI-radius); padding: 12px; margin-top: 8px; } @@ -449,7 +443,7 @@ const isDeleted = ref(false); .quoteNote { padding: 16px; - border: dashed 1px var(--renote); + border: dashed 1px var(--MI_THEME-renote); border-radius: 8px; overflow: clip; } @@ -473,7 +467,7 @@ const isDeleted = ref(false); } &:hover { - color: var(--fgHighlighted); + color: var(--MI_THEME-fgHighlighted); } } @@ -550,7 +544,7 @@ const isDeleted = ref(false); margin: 0 10px 0 0; width: 46px; height: 46px; - top: calc(14px + var(--stickyTop, 0px)); + top: calc(14px + var(--MI-stickyTop, 0px)); } } diff --git a/packages/frontend-embed/src/components/EmNoteDetailed.vue b/packages/frontend-embed/src/components/EmNoteDetailed.vue index 360de318641e..b39b47c06509 100644 --- a/packages/frontend-embed/src/components/EmNoteDetailed.vue +++ b/packages/frontend-embed/src/components/EmNoteDetailed.vue @@ -195,7 +195,7 @@ const collapsed = ref(appearNote.value.cw == null && isLong); padding: 16px 32px 8px 32px; line-height: 28px; white-space: pre; - color: var(--renote); + color: var(--MI_THEME-renote); } .renoteAvatar { @@ -281,7 +281,7 @@ const collapsed = ref(appearNote.value.cw == null && isLong); padding: 4px 6px; font-size: 80%; line-height: 1; - border: solid 0.5px var(--divider); + border: solid 0.5px var(--MI_THEME-divider); border-radius: 4px; } @@ -323,14 +323,14 @@ const collapsed = ref(appearNote.value.cw == null && isLong); } .noteReplyTarget { - color: var(--accent); + color: var(--MI_THEME-accent); margin-right: 0.5em; } .rn { margin-left: 4px; font-style: oblique; - color: var(--renote); + color: var(--MI_THEME-renote); } .reactionOmitted { @@ -350,7 +350,7 @@ const collapsed = ref(appearNote.value.cw == null && isLong); .quoteNote { padding: 16px; - border: dashed 1px var(--renote); + border: dashed 1px var(--MI_THEME-renote); border-radius: 8px; overflow: clip; } @@ -364,12 +364,12 @@ const collapsed = ref(appearNote.value.cw == null && isLong); width: 100%; margin-top: 14px; position: sticky; - bottom: calc(var(--stickyBottom, 0px) + 14px); + bottom: calc(var(--MI-stickyBottom, 0px) + 14px); } .showLessLabel { display: inline-block; - background: var(--popup); + background: var(--MI_THEME-popup); padding: 6px 10px; font-size: 0.8em; border-radius: 999px; @@ -390,16 +390,16 @@ const collapsed = ref(appearNote.value.cw == null && isLong); z-index: 2; width: 100%; height: 64px; - background: linear-gradient(0deg, var(--panel), var(--X15)); + background: linear-gradient(0deg, var(--MI_THEME-panel), var(--MI_THEME-X15)); &:hover > .collapsedLabel { - background: var(--panelHighlight); + background: var(--MI_THEME-panelHighlight); } } .collapsedLabel { display: inline-block; - background: var(--panel); + background: var(--MI_THEME-panel); padding: 6px 10px; font-size: 0.8em; border-radius: 999px; @@ -422,7 +422,7 @@ const collapsed = ref(appearNote.value.cw == null && isLong); } &:hover { - color: var(--fgHighlighted); + color: var(--MI_THEME-fgHighlighted); } } @@ -438,7 +438,7 @@ const collapsed = ref(appearNote.value.cw == null && isLong); opacity: 0.7; &.reacted { - color: var(--accent); + color: var(--MI_THEME-accent); } } diff --git a/packages/frontend-embed/src/components/EmNoteHeader.vue b/packages/frontend-embed/src/components/EmNoteHeader.vue index 7d0b9bacadc6..85b4aac07130 100644 --- a/packages/frontend-embed/src/components/EmNoteHeader.vue +++ b/packages/frontend-embed/src/components/EmNoteHeader.vue @@ -72,7 +72,7 @@ defineProps<{ margin: 0 .5em 0 0; padding: 1px 6px; font-size: 80%; - border: solid 0.5px var(--divider); + border: solid 0.5px var(--MI_THEME-divider); border-radius: 3px; } diff --git a/packages/frontend-embed/src/components/EmNoteSimple.vue b/packages/frontend-embed/src/components/EmNoteSimple.vue index 704a876e5921..b9aaf3fa4ac0 100644 --- a/packages/frontend-embed/src/components/EmNoteSimple.vue +++ b/packages/frontend-embed/src/components/EmNoteSimple.vue @@ -53,7 +53,7 @@ const showContent = ref(false); height: 34px; border-radius: 8px; position: sticky !important; - top: calc(16px + var(--stickyTop, 0px)); + top: calc(16px + var(--MI-stickyTop, 0px)); left: 0; } diff --git a/packages/frontend-embed/src/components/EmNoteSub.vue b/packages/frontend-embed/src/components/EmNoteSub.vue index f60aea3e7e88..59be8608e056 100644 --- a/packages/frontend-embed/src/components/EmNoteSub.vue +++ b/packages/frontend-embed/src/components/EmNoteSub.vue @@ -123,7 +123,7 @@ if (props.detail) { } .reply, .more { - border-left: solid 0.5px var(--divider); + border-left: solid 0.5px var(--MI_THEME-divider); margin-top: 10px; } @@ -144,7 +144,7 @@ if (props.detail) { .muted { text-align: center; padding: 8px !important; - border: 1px solid var(--divider); + border: 1px solid var(--MI_THEME-divider); margin: 8px 8px 0 8px; border-radius: 8px; } diff --git a/packages/frontend-embed/src/components/EmNotes.vue b/packages/frontend-embed/src/components/EmNotes.vue index 3418d97f77e4..4211261e1974 100644 --- a/packages/frontend-embed/src/components/EmNotes.vue +++ b/packages/frontend-embed/src/components/EmNotes.vue @@ -43,10 +43,10 @@ defineExpose({ diff --git a/packages/frontend-embed/src/components/EmPoll.vue b/packages/frontend-embed/src/components/EmPoll.vue index a2b120344940..d197e094c6d2 100644 --- a/packages/frontend-embed/src/components/EmPoll.vue +++ b/packages/frontend-embed/src/components/EmPoll.vue @@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only
  • - + ({{ i18n.tsx._poll.votesCount({ n: choice.votes }) }}) @@ -52,8 +52,8 @@ const total = computed(() => sum(props.poll.choices.map(x => x.votes))); position: relative; margin: 4px 0; padding: 4px; - //border: solid 0.5px var(--divider); - background: var(--accentedBg); + //border: solid 0.5px var(--MI_THEME-divider); + background: var(--MI_THEME-accentedBg); border-radius: 4px; overflow: clip; } @@ -63,8 +63,8 @@ const total = computed(() => sum(props.poll.choices.map(x => x.votes))); top: 0; left: 0; height: 100%; - background: var(--accent); - background: linear-gradient(90deg,var(--buttonGradateA),var(--buttonGradateB)); + background: var(--MI_THEME-accent); + background: linear-gradient(90deg,var(--MI_THEME-buttonGradateA),var(--MI_THEME-buttonGradateB)); transition: width 1s ease; } @@ -72,11 +72,11 @@ const total = computed(() => sum(props.poll.choices.map(x => x.votes))); position: relative; display: inline-block; padding: 3px 5px; - background: var(--panel); + background: var(--MI_THEME-panel); border-radius: 3px; } .info { - color: var(--fg); + color: var(--MI_THEME-fg); } diff --git a/packages/frontend-embed/src/components/EmReactionsViewer.reaction.vue b/packages/frontend-embed/src/components/EmReactionsViewer.reaction.vue index 2e43eb8d170b..2ebff489fd7b 100644 --- a/packages/frontend-embed/src/components/EmReactionsViewer.reaction.vue +++ b/packages/frontend-embed/src/components/EmReactionsViewer.reaction.vue @@ -38,7 +38,7 @@ const props = defineProps<{ justify-content: center; &.canToggle { - background: var(--buttonBg); + background: var(--MI_THEME-buttonBg); &:hover { background: rgba(0, 0, 0, 0.1); @@ -72,12 +72,12 @@ const props = defineProps<{ } &.reacted, &.reacted:hover { - background: var(--accentedBg); - color: var(--accent); - box-shadow: 0 0 0 1px var(--accent) inset; + background: var(--MI_THEME-accentedBg); + color: var(--MI_THEME-accent); + box-shadow: 0 0 0 1px var(--MI_THEME-accent) inset; > .count { - color: var(--accent); + color: var(--MI_THEME-accent); } > .icon { diff --git a/packages/frontend-embed/src/components/EmSubNoteContent.vue b/packages/frontend-embed/src/components/EmSubNoteContent.vue index db2666a45f47..61815ddfd82f 100644 --- a/packages/frontend-embed/src/components/EmSubNoteContent.vue +++ b/packages/frontend-embed/src/components/EmSubNoteContent.vue @@ -65,11 +65,11 @@ const collapsed = ref(isLong); left: 0; width: 100%; height: 64px; - background: linear-gradient(0deg, var(--panel), color(from var(--panel) srgb r g b / 0)); + background: linear-gradient(0deg, var(--MI_THEME-panel), color(from var(--MI_THEME-panel) srgb r g b / 0)); > .fadeLabel { display: inline-block; - background: var(--panel); + background: var(--MI_THEME-panel); padding: 6px 10px; font-size: 0.8em; border-radius: 999px; @@ -78,7 +78,7 @@ const collapsed = ref(isLong); &:hover { > .fadeLabel { - background: var(--panelHighlight); + background: var(--MI_THEME-panelHighlight); } } } @@ -87,25 +87,25 @@ const collapsed = ref(isLong); .reply { margin-right: 6px; - color: var(--accent); + color: var(--MI_THEME-accent); } .rp { margin-left: 4px; font-style: oblique; - color: var(--renote); + color: var(--MI_THEME-renote); } .showLess { width: 100%; margin-top: 14px; position: sticky; - bottom: calc(var(--stickyBottom, 0px) + 14px); + bottom: calc(var(--MI-stickyBottom, 0px) + 14px); } .showLessLabel { display: inline-block; - background: var(--popup); + background: var(--MI_THEME-popup); padding: 6px 10px; font-size: 0.8em; border-radius: 999px; diff --git a/packages/frontend-embed/src/components/EmTime.vue b/packages/frontend-embed/src/components/EmTime.vue index c3986f7d7031..7902e1848323 100644 --- a/packages/frontend-embed/src/components/EmTime.vue +++ b/packages/frontend-embed/src/components/EmTime.vue @@ -98,10 +98,10 @@ if (!invalid && props.origin === null && (props.mode === 'relative' || props.mod diff --git a/packages/frontend-embed/src/components/EmTimelineContainer.vue b/packages/frontend-embed/src/components/EmTimelineContainer.vue index 6c30b1102d9e..60fd67ced918 100644 --- a/packages/frontend-embed/src/components/EmTimelineContainer.vue +++ b/packages/frontend-embed/src/components/EmTimelineContainer.vue @@ -20,7 +20,7 @@ withDefaults(defineProps<{ diff --git a/packages/frontend-embed/src/pages/tag.vue b/packages/frontend-embed/src/pages/tag.vue index b481b3ebe552..4b00ae7c2d3e 100644 --- a/packages/frontend-embed/src/pages/tag.vue +++ b/packages/frontend-embed/src/pages/tag.vue @@ -83,7 +83,7 @@ function top(ev: MouseEvent) { display: flex; min-width: 0; align-items: center; - gap: var(--margin); + gap: var(--MI-margin); overflow: hidden; .headerClipIconRoot { @@ -93,8 +93,8 @@ function top(ev: MouseEvent) { line-height: 32px; font-size: 14px; text-align: center; - background-color: var(--accentedBg); - color: var(--accent); + background-color: var(--MI_THEME-accentedBg); + color: var(--MI_THEME-accent); border-radius: 50%; } diff --git a/packages/frontend-embed/src/pages/user-timeline.vue b/packages/frontend-embed/src/pages/user-timeline.vue index 85e6f52d5079..348b1a762213 100644 --- a/packages/frontend-embed/src/pages/user-timeline.vue +++ b/packages/frontend-embed/src/pages/user-timeline.vue @@ -117,7 +117,7 @@ function top(ev: MouseEvent) { display: flex; min-width: 0; align-items: center; - gap: var(--margin); + gap: var(--MI-margin); overflow: hidden; .avatarLink { diff --git a/packages/frontend-embed/src/style.scss b/packages/frontend-embed/src/style.scss index 02008ddbd05b..2e43cfd20adc 100644 --- a/packages/frontend-embed/src/style.scss +++ b/packages/frontend-embed/src/style.scss @@ -7,18 +7,18 @@ */ :root { - --radius: 12px; - --marginFull: 14px; - --marginHalf: 10px; + --MI-radius: 12px; + --MI-marginFull: 14px; + --MI-marginHalf: 10px; - --margin: var(--marginFull); + --MI-margin: var(--MI-marginFull); } html { background-color: transparent; color-scheme: light dark; - color: var(--fg); - accent-color: var(--accent); + color: var(--MI_THEME-fg); + accent-color: var(--MI_THEME-accent); overflow: clip; overflow-wrap: break-word; font-family: 'Hiragino Maru Gothic Pro', "BIZ UDGothic", Roboto, HelveticaNeue, Arial, sans-serif; @@ -29,7 +29,7 @@ html { -webkit-text-size-adjust: 100%; &, * { - scrollbar-color: var(--scrollbarHandle) transparent; + scrollbar-color: var(--MI_THEME-scrollbarHandle) transparent; scrollbar-width: thin; &::-webkit-scrollbar { @@ -42,14 +42,14 @@ html { } &::-webkit-scrollbar-thumb { - background: var(--scrollbarHandle); + background: var(--MI_THEME-scrollbarHandle); &:hover { - background: var(--scrollbarHandleHover); + background: var(--MI_THEME-scrollbarHandleHover); } &:active { - background: var(--accent); + background: var(--MI_THEME-accent); } } } @@ -93,7 +93,7 @@ rt { } :focus-visible { - outline: var(--focus) solid 2px; + outline: var(--MI_THEME-focus) solid 2px; outline-offset: -2px; &:hover { @@ -151,38 +151,38 @@ rt { ._buttonGray { @extend ._button; - background: var(--buttonBg); + background: var(--MI_THEME-buttonBg); &:not(:disabled):hover { - background: var(--buttonHoverBg); + background: var(--MI_THEME-buttonHoverBg); } } ._buttonPrimary { @extend ._button; - color: var(--fgOnAccent); - background: var(--accent); + color: var(--MI_THEME-fgOnAccent); + background: var(--MI_THEME-accent); &:not(:disabled):hover { - background: hsl(from var(--accent) h s calc(l + 5)); + background: hsl(from var(--MI_THEME-accent) h s calc(l + 5)); } &:not(:disabled):active { - background: hsl(from var(--accent) h s calc(l - 5)); + background: hsl(from var(--MI_THEME-accent) h s calc(l - 5)); } } ._buttonGradate { @extend ._buttonPrimary; - color: var(--fgOnAccent); - background: linear-gradient(90deg, var(--buttonGradateA), var(--buttonGradateB)); + color: var(--MI_THEME-fgOnAccent); + background: linear-gradient(90deg, var(--MI_THEME-buttonGradateA), var(--MI_THEME-buttonGradateB)); &:not(:disabled):hover { - background: linear-gradient(90deg, hsl(from var(--accent) h s calc(l + 5)), hsl(from var(--accent) h s calc(l + 5))); + background: linear-gradient(90deg, hsl(from var(--MI_THEME-accent) h s calc(l + 5)), hsl(from var(--MI_THEME-accent) h s calc(l + 5))); } &:not(:disabled):active { - background: linear-gradient(90deg, hsl(from var(--accent) h s calc(l + 5)), hsl(from var(--accent) h s calc(l + 5))); + background: linear-gradient(90deg, hsl(from var(--MI_THEME-accent) h s calc(l + 5)), hsl(from var(--MI_THEME-accent) h s calc(l + 5))); } } @@ -199,13 +199,13 @@ rt { } ._help { - color: var(--accent); + color: var(--MI_THEME-accent); cursor: help; } ._textButton { @extend ._button; - color: var(--accent); + color: var(--MI_THEME-accent); &:focus-visible { outline-offset: 2px; @@ -217,13 +217,13 @@ rt { } ._panel { - background: var(--panel); - border-radius: var(--radius); + background: var(--MI_THEME-panel); + border-radius: var(--MI-radius); overflow: clip; } ._margin { - margin: var(--margin) 0; + margin: var(--MI-margin) 0; } ._gaps_m { @@ -241,7 +241,7 @@ rt { ._gaps { display: flex; flex-direction: column; - gap: var(--margin); + gap: var(--MI-margin); } ._buttons { @@ -263,24 +263,24 @@ rt { padding: 10px; box-sizing: border-box; text-align: center; - border: solid 0.5px var(--divider); - border-radius: var(--radius); + border: solid 0.5px var(--MI_THEME-divider); + border-radius: var(--MI-radius); &:active { - border-color: var(--accent); + border-color: var(--MI_THEME-accent); } } ._popup { - background: var(--popup); - border-radius: var(--radius); + background: var(--MI_THEME-popup); + border-radius: var(--MI-radius); contain: content; } ._acrylic { - background: var(--acrylicPanel); - -webkit-backdrop-filter: var(--blur, blur(15px)); - backdrop-filter: var(--blur, blur(15px)); + background: var(--MI_THEME-acrylicPanel); + -webkit-backdrop-filter: var(--MI-blur, blur(15px)); + backdrop-filter: var(--MI-blur, blur(15px)); } ._fullinfo { @@ -296,7 +296,7 @@ rt { } ._link { - color: var(--link); + color: var(--MI_THEME-link); } ._caption { diff --git a/packages/frontend-embed/src/theme.ts b/packages/frontend-embed/src/theme.ts index 23e70cd0d375..4664ad48804e 100644 --- a/packages/frontend-embed/src/theme.ts +++ b/packages/frontend-embed/src/theme.ts @@ -61,7 +61,7 @@ export function applyTheme(theme: Theme, persist = true) { } for (const [k, v] of Object.entries(props)) { - document.documentElement.style.setProperty(`--${k}`, v.toString()); + document.documentElement.style.setProperty(`--MI_THEME-${k}`, v.toString()); } // iframeを正常に透過させるために、cssのcolor-schemeは `light dark;` 固定にしてある。style.scss参照 diff --git a/packages/frontend-embed/src/ui.vue b/packages/frontend-embed/src/ui.vue index 8da5f46a96e8..4ba5968a91f1 100644 --- a/packages/frontend-embed/src/ui.vue +++ b/packages/frontend-embed/src/ui.vue @@ -88,14 +88,14 @@ onUnmounted(() => { diff --git a/packages/frontend/src/components/MkAccountMoved.vue b/packages/frontend/src/components/MkAccountMoved.vue index 796524fce949..0839955d9d93 100644 --- a/packages/frontend/src/components/MkAccountMoved.vue +++ b/packages/frontend/src/components/MkAccountMoved.vue @@ -32,9 +32,9 @@ misskeyApi('users/show', { userId: props.movedTo }).then(u => user.value = u); .root { padding: 16px; font-size: 90%; - background: var(--infoWarnBg); - color: var(--error); - border-radius: var(--radius); + background: var(--MI_THEME-infoWarnBg); + color: var(--MI_THEME-error); + border-radius: var(--MI-radius); } .link { diff --git a/packages/frontend/src/components/MkAnalogClock.vue b/packages/frontend/src/components/MkAnalogClock.vue index 835efbd6cd71..c8fa6246e01a 100644 --- a/packages/frontend/src/components/MkAnalogClock.vue +++ b/packages/frontend/src/components/MkAnalogClock.vue @@ -193,12 +193,12 @@ tick(); function calcColors() { const computedStyle = getComputedStyle(document.documentElement); - const dark = tinycolor(computedStyle.getPropertyValue('--bg')).isDark(); - const accent = tinycolor(computedStyle.getPropertyValue('--accent')).toHexString(); + const dark = tinycolor(computedStyle.getPropertyValue('--MI_THEME-bg')).isDark(); + const accent = tinycolor(computedStyle.getPropertyValue('--MI_THEME-accent')).toHexString(); majorGraduationColor.value = dark ? 'rgba(255, 255, 255, 0.3)' : 'rgba(0, 0, 0, 0.3)'; //minorGraduationColor = dark ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)'; sHandColor.value = dark ? 'rgba(255, 255, 255, 0.5)' : 'rgba(0, 0, 0, 0.3)'; - mHandColor.value = tinycolor(computedStyle.getPropertyValue('--fg')).toHexString(); + mHandColor.value = tinycolor(computedStyle.getPropertyValue('--MI_THEME-fg')).toHexString(); hHandColor.value = accent; nowColor.value = accent; } diff --git a/packages/frontend/src/components/MkAnnouncementDialog.vue b/packages/frontend/src/components/MkAnnouncementDialog.vue index f27694658ef0..3045a4758590 100644 --- a/packages/frontend/src/components/MkAnnouncementDialog.vue +++ b/packages/frontend/src/components/MkAnnouncementDialog.vue @@ -9,9 +9,9 @@ SPDX-License-Identifier: AGPL-3.0-only
    - - - + + + {{ announcement.title }}
    @@ -29,7 +29,7 @@ import { misskeyApi } from '@/scripts/misskey-api.js'; import MkModal from '@/components/MkModal.vue'; import MkButton from '@/components/MkButton.vue'; import { i18n } from '@/i18n.js'; -import { $i, updateAccount } from '@/account.js'; +import { $i, updateAccountPartial } from '@/account.js'; const props = withDefaults(defineProps<{ announcement: Misskey.entities.Announcement; @@ -51,7 +51,7 @@ async function ok() { modal.value?.close(); misskeyApi('i/read-announcement', { announcementId: props.announcement.id }); - updateAccount({ + updateAccountPartial({ unreadAnnouncements: $i!.unreadAnnouncements.filter(a => a.id !== props.announcement.id), }); } @@ -83,8 +83,8 @@ onMounted(() => { min-width: 320px; max-width: 480px; box-sizing: border-box; - background: var(--panel); - border-radius: var(--radius); + background: var(--MI_THEME-panel); + border-radius: var(--MI-radius); } .header { diff --git a/packages/frontend/src/components/MkAntennaEditor.vue b/packages/frontend/src/components/MkAntennaEditor.vue index cb7ee3d6ca38..e622d57f1ecf 100644 --- a/packages/frontend/src/components/MkAntennaEditor.vue +++ b/packages/frontend/src/components/MkAntennaEditor.vue @@ -160,7 +160,7 @@ async function deleteAntenna() { function addUser() { os.selectUser({ includeSelf: true }).then(user => { users.value = users.value.trim(); - users.value += '\n@' + Misskey.acct.toString(user as any); + users.value += '\n@' + Misskey.acct.toString(user); users.value = users.value.trim(); }); } @@ -170,6 +170,6 @@ function addUser() { .actions { margin-top: 16px; padding: 24px 0; - border-top: solid 0.5px var(--divider); + border-top: solid 0.5px var(--MI_THEME-divider); } diff --git a/packages/frontend/src/components/MkAsUi.vue b/packages/frontend/src/components/MkAsUi.vue index b50a7fea5c47..e52ab5ccad15 100644 --- a/packages/frontend/src/components/MkAsUi.vue +++ b/packages/frontend/src/components/MkAsUi.vue @@ -106,7 +106,7 @@ const containerStyle = computed(() => { const border = isBordered ? { borderWidth: c.borderWidth ?? '1px', - borderColor: c.borderColor ?? 'var(--divider)', + borderColor: c.borderColor ?? 'var(--MI_THEME-divider)', borderStyle: c.borderStyle ?? 'solid', } : undefined; @@ -165,7 +165,7 @@ function openPostForm() { } .postForm { - background: var(--bg); + background: var(--MI_THEME-bg); border-radius: 8px; } diff --git a/packages/frontend/src/components/MkAuthConfirm.stories.impl.ts b/packages/frontend/src/components/MkAuthConfirm.stories.impl.ts new file mode 100644 index 000000000000..0adc44e204d7 --- /dev/null +++ b/packages/frontend/src/components/MkAuthConfirm.stories.impl.ts @@ -0,0 +1,7 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import MkAuthConfirm from './MkAuthConfirm.vue'; +void MkAuthConfirm; diff --git a/packages/frontend/src/components/MkAuthConfirm.vue b/packages/frontend/src/components/MkAuthConfirm.vue new file mode 100644 index 000000000000..f78d2d38f024 --- /dev/null +++ b/packages/frontend/src/components/MkAuthConfirm.vue @@ -0,0 +1,450 @@ + + + + + + + diff --git a/packages/frontend/src/components/MkAutocomplete.vue b/packages/frontend/src/components/MkAutocomplete.vue index f54799136937..0ea4566d4e6a 100644 --- a/packages/frontend/src/components/MkAutocomplete.vue +++ b/packages/frontend/src/components/MkAutocomplete.vue @@ -407,16 +407,16 @@ onBeforeUnmount(() => { text-overflow: ellipsis; &:hover { - background: var(--X3); + background: var(--MI_THEME-X3); } &[data-selected='true'] { - background: var(--accent); + background: var(--MI_THEME-accent); color: #fff !important; } &:active { - background: var(--accentDarken); + background: var(--MI_THEME-accentDarken); color: #fff !important; } } diff --git a/packages/frontend/src/components/MkButton.vue b/packages/frontend/src/components/MkButton.vue index 1156b3f2b8c1..311facb4aaf1 100644 --- a/packages/frontend/src/components/MkButton.vue +++ b/packages/frontend/src/components/MkButton.vue @@ -129,7 +129,7 @@ function onMousedown(evt: MouseEvent): void { font-size: 95%; box-shadow: none; text-decoration: none; - background: var(--buttonBg); + background: var(--MI_THEME-buttonBg); border-radius: 5px; overflow: clip; box-sizing: border-box; @@ -140,11 +140,11 @@ function onMousedown(evt: MouseEvent): void { } &:not(:disabled):hover { - background: var(--buttonHoverBg); + background: var(--MI_THEME-buttonHoverBg); } &:not(:disabled):active { - background: var(--buttonHoverBg); + background: var(--MI_THEME-buttonHoverBg); } &.small { @@ -167,15 +167,15 @@ function onMousedown(evt: MouseEvent): void { &.primary { font-weight: bold; - color: var(--fgOnAccent) !important; - background: var(--accent); + color: var(--MI_THEME-fgOnAccent) !important; + background: var(--MI_THEME-accent); &:not(:disabled):hover { - background: hsl(from var(--accent) h s calc(l + 5)); + background: hsl(from var(--MI_THEME-accent) h s calc(l + 5)); } &:not(:disabled):active { - background: hsl(from var(--accent) h s calc(l + 5)); + background: hsl(from var(--MI_THEME-accent) h s calc(l + 5)); } } @@ -216,15 +216,15 @@ function onMousedown(evt: MouseEvent): void { &.gradate { font-weight: bold; - color: var(--fgOnAccent) !important; - background: linear-gradient(90deg, var(--buttonGradateA), var(--buttonGradateB)); + color: var(--MI_THEME-fgOnAccent) !important; + background: linear-gradient(90deg, var(--MI_THEME-buttonGradateA), var(--MI_THEME-buttonGradateB)); &:not(:disabled):hover { - background: linear-gradient(90deg, hsl(from var(--accent) h s calc(l + 5)), hsl(from var(--accent) h s calc(l + 5))); + background: linear-gradient(90deg, hsl(from var(--MI_THEME-accent) h s calc(l + 5)), hsl(from var(--MI_THEME-accent) h s calc(l + 5))); } &:not(:disabled):active { - background: linear-gradient(90deg, hsl(from var(--accent) h s calc(l + 5)), hsl(from var(--accent) h s calc(l + 5))); + background: linear-gradient(90deg, hsl(from var(--MI_THEME-accent) h s calc(l + 5)), hsl(from var(--MI_THEME-accent) h s calc(l + 5))); } } diff --git a/packages/frontend/src/components/MkCaptcha.vue b/packages/frontend/src/components/MkCaptcha.vue index c5b6e0caede7..264cf9af069b 100644 --- a/packages/frontend/src/components/MkCaptcha.vue +++ b/packages/frontend/src/components/MkCaptcha.vue @@ -10,6 +10,17 @@ SPDX-License-Identifier: AGPL-3.0-only
  • +
    + +
    +
    Test captcha passed!
    +
    +
    +
    Type "ai-chan-kawaii" to pass captcha
    + + +
    +
    @@ -29,7 +40,7 @@ export type Captcha = { getResponse(id: string): string; }; -export type CaptchaProvider = 'hcaptcha' | 'recaptcha' | 'turnstile' | 'mcaptcha'; +export type CaptchaProvider = 'hcaptcha' | 'recaptcha' | 'turnstile' | 'mcaptcha' | 'testcaptcha'; type CaptchaContainer = { readonly [_ in CaptchaProvider]?: Captcha; @@ -54,12 +65,16 @@ const available = ref(false); const captchaEl = shallowRef(); +const testcaptchaInput = ref(''); +const testcaptchaPassed = ref(false); + const variable = computed(() => { switch (props.provider) { case 'hcaptcha': return 'hcaptcha'; case 'recaptcha': return 'grecaptcha'; case 'turnstile': return 'turnstile'; case 'mcaptcha': return 'mcaptcha'; + case 'testcaptcha': return 'testcaptcha'; } }); @@ -71,6 +86,7 @@ const src = computed(() => { case 'recaptcha': return 'https://www.recaptcha.net/recaptcha/api.js?render=explicit'; case 'turnstile': return 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit'; case 'mcaptcha': return null; + case 'testcaptcha': return null; } }); @@ -78,7 +94,7 @@ const scriptId = computed(() => `script-${props.provider}`); const captcha = computed(() => window[variable.value] || {} as unknown as Captcha); -if (loaded || props.provider === 'mcaptcha') { +if (loaded || props.provider === 'mcaptcha' || props.provider === 'testcaptcha') { available.value = true; } else if (src.value !== null) { (document.getElementById(scriptId.value) ?? document.head.appendChild(Object.assign(document.createElement('script'), { @@ -91,6 +107,8 @@ if (loaded || props.provider === 'mcaptcha') { function reset() { if (captcha.value.reset) captcha.value.reset(); + testcaptchaPassed.value = false; + testcaptchaInput.value = ''; } async function requestRender() { @@ -99,8 +117,8 @@ async function requestRender() { sitekey: props.sitekey, theme: defaultStore.state.darkMode ? 'dark' : 'light', callback: callback, - 'expired-callback': callback, - 'error-callback': callback, + 'expired-callback': () => callback(undefined), + 'error-callback': () => callback(undefined), }); } else if (props.provider === 'mcaptcha' && props.instanceUrl && props.sitekey) { const { default: Widget } = await import('@mcaptcha/vanilla-glue'); @@ -127,6 +145,12 @@ function onReceivedMessage(message: MessageEvent) { } } +function testcaptchaSubmit() { + testcaptchaPassed.value = testcaptchaInput.value === 'ai-chan-kawaii'; + callback(testcaptchaPassed.value ? 'testcaptcha-passed' : undefined); + if (!testcaptchaPassed.value) testcaptchaInput.value = ''; +} + onMounted(() => { if (available.value) { window.addEventListener('message', onReceivedMessage); diff --git a/packages/frontend/src/components/MkChannelFollowButton.vue b/packages/frontend/src/components/MkChannelFollowButton.vue index 35dc3ad4bf83..d4e4f6179a83 100644 --- a/packages/frontend/src/components/MkChannelFollowButton.vue +++ b/packages/frontend/src/components/MkChannelFollowButton.vue @@ -68,9 +68,9 @@ async function onClick() { position: relative; display: inline-block; font-weight: bold; - color: var(--accent); + color: var(--MI_THEME-accent); background: transparent; - border: solid 1px var(--accent); + border: solid 1px var(--MI_THEME-accent); padding: 0; height: 31px; font-size: 16px; @@ -99,17 +99,17 @@ async function onClick() { } &.active { - color: var(--fgOnAccent); - background: var(--accent); + color: var(--MI_THEME-fgOnAccent); + background: var(--MI_THEME-accent); &:hover { - background: var(--accentLighten); - border-color: var(--accentLighten); + background: var(--MI_THEME-accentLighten); + border-color: var(--MI_THEME-accentLighten); } &:active { - background: var(--accentDarken); - border-color: var(--accentDarken); + background: var(--MI_THEME-accentDarken); + border-color: var(--MI_THEME-accentDarken); } } diff --git a/packages/frontend/src/components/MkChannelPreview.vue b/packages/frontend/src/components/MkChannelPreview.vue index 3c0874a1eb76..c470042b79ac 100644 --- a/packages/frontend/src/components/MkChannelPreview.vue +++ b/packages/frontend/src/components/MkChannelPreview.vue @@ -47,11 +47,12 @@ SPDX-License-Identifier: AGPL-3.0-only diff --git a/packages/frontend/src/components/MkEmojiPicker.vue b/packages/frontend/src/components/MkEmojiPicker.vue index 3bad8da06f72..8187d991e771 100644 --- a/packages/frontend/src/components/MkEmojiPicker.vue +++ b/packages/frontend/src/components/MkEmojiPicker.vue @@ -409,7 +409,7 @@ function computeButtonTitle(ev: MouseEvent): void { elm.title = getEmojiName(emoji); } -function chosen(emoji: any, ev?: MouseEvent) { +function chosen(emoji: string | Misskey.entities.EmojiSimple | UnicodeEmojiDef, ev?: MouseEvent) { const el = ev && (ev.currentTarget ?? ev.target) as HTMLElement | null | undefined; if (el) { const rect = el.getBoundingClientRect(); @@ -426,7 +426,7 @@ function chosen(emoji: any, ev?: MouseEvent) { // 最近使った絵文字更新 if (!pinned.value?.includes(key)) { let recents = defaultStore.state.recentlyUsedEmojis; - recents = recents.filter((emoji: any) => emoji !== key); + recents = recents.filter((emoji) => emoji !== key); recents.unshift(key); defaultStore.set('recentlyUsedEmojis', recents.splice(0, 32)); } @@ -580,7 +580,7 @@ defineExpose({ &:disabled { cursor: not-allowed; - background: linear-gradient(-45deg, transparent 0% 48%, var(--X6) 48% 52%, transparent 52% 100%); + background: linear-gradient(-45deg, transparent 0% 48%, var(--MI_THEME-X6) 48% 52%, transparent 52% 100%); opacity: 1; > .emoji { @@ -615,7 +615,7 @@ defineExpose({ &:disabled { cursor: not-allowed; - background: linear-gradient(-45deg, transparent 0% 48%, var(--X6) 48% 52%, transparent 52% 100%); + background: linear-gradient(-45deg, transparent 0% 48%, var(--MI_THEME-X6) 48% 52%, transparent 52% 100%); opacity: 1; > .emoji { @@ -638,7 +638,7 @@ defineExpose({ outline: none; border: none; background: transparent; - color: var(--fg); + color: var(--MI_THEME-fg); &:not(:focus):not(.filled) { margin-bottom: env(safe-area-inset-bottom, 0px); @@ -647,7 +647,7 @@ defineExpose({ &:not(.filled) { order: 1; z-index: 2; - box-shadow: 0px -1px 0 0px var(--divider); + box-shadow: 0px -1px 0 0px var(--MI_THEME-divider); } } @@ -658,11 +658,11 @@ defineExpose({ > .tab { flex: 1; height: 38px; - border-top: solid 0.5px var(--divider); + border-top: solid 0.5px var(--MI_THEME-divider); &.active { - border-top: solid 1px var(--accent); - color: var(--accent); + border-top: solid 1px var(--MI_THEME-accent); + color: var(--MI_THEME-accent); } } } @@ -681,7 +681,7 @@ defineExpose({ > .group { &:not(.index) { padding: 4px 0 8px 0; - border-top: solid 0.5px var(--divider); + border-top: solid 0.5px var(--MI_THEME-divider); } > header { @@ -708,7 +708,7 @@ defineExpose({ cursor: pointer; &:hover { - color: var(--accent); + color: var(--MI_THEME-accent); } } @@ -730,13 +730,13 @@ defineExpose({ } &:active { - background: var(--accent); + background: var(--MI_THEME-accent); box-shadow: inset 0 0.15em 0.3em rgba(27, 31, 35, 0.15); } &:disabled { cursor: not-allowed; - background: linear-gradient(-45deg, transparent 0% 48%, var(--X6) 48% 52%, transparent 52% 100%); + background: linear-gradient(-45deg, transparent 0% 48%, var(--MI_THEME-X6) 48% 52%, transparent 52% 100%); opacity: 1; > .emoji { @@ -757,7 +757,7 @@ defineExpose({ } &.result { - border-bottom: solid 0.5px var(--divider); + border-bottom: solid 0.5px var(--MI_THEME-divider); &:empty { display: none; diff --git a/packages/frontend/src/components/MkExtensionInstaller.stories.impl.ts b/packages/frontend/src/components/MkExtensionInstaller.stories.impl.ts new file mode 100644 index 000000000000..6763f7c54692 --- /dev/null +++ b/packages/frontend/src/components/MkExtensionInstaller.stories.impl.ts @@ -0,0 +1,83 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { StoryObj } from '@storybook/vue3'; +import MkExtensionInstaller from './MkExtensionInstaller.vue'; +import lightTheme from '@@/themes/_light.json5'; + +export const Plugin = { + render(args) { + return { + components: { + MkExtensionInstaller, + }, + setup() { + return { + args, + }; + }, + computed: { + props() { + return { + ...this.args, + }; + }, + }, + template: '', + }; + }, + args: { + extension: { + type: 'plugin', + raw: '"do nothing"', + meta: { + name: 'do nothing plugin', + version: '1.0', + author: 'syuilo and misskey-project', + description: 'a plugin that does nothing', + permissions: ['read:account'], + config: { + 'doNothing': true, + }, + }, + }, + }, + parameters: { + layout: 'centered', + }, +} satisfies StoryObj; + +export const Theme = { + render(args) { + return { + components: { + MkExtensionInstaller, + }, + setup() { + return { + args, + }; + }, + computed: { + props() { + return { + ...this.args, + }; + }, + }, + template: '', + }; + }, + args: { + extension: { + type: 'theme', + raw: JSON.stringify(lightTheme), + meta: lightTheme, + }, + }, + parameters: { + layout: 'centered', + }, +} satisfies StoryObj; diff --git a/packages/frontend/src/components/MkExtensionInstaller.vue b/packages/frontend/src/components/MkExtensionInstaller.vue new file mode 100644 index 000000000000..d59b20435e31 --- /dev/null +++ b/packages/frontend/src/components/MkExtensionInstaller.vue @@ -0,0 +1,146 @@ + + + + + + + + diff --git a/packages/frontend/src/components/MkFileListForAdmin.vue b/packages/frontend/src/components/MkFileListForAdmin.vue index 13295c455b7c..d5d32ebb285e 100644 --- a/packages/frontend/src/components/MkFileListForAdmin.vue +++ b/packages/frontend/src/components/MkFileListForAdmin.vue @@ -66,7 +66,7 @@ const props = defineProps<{ align-items: center; &:hover { - color: var(--accent); + color: var(--MI_THEME-accent); } > .thumbnail { diff --git a/packages/frontend/src/components/MkFlashPreview.vue b/packages/frontend/src/components/MkFlashPreview.vue index 8a2a4386240a..b7278ac742fb 100644 --- a/packages/frontend/src/components/MkFlashPreview.vue +++ b/packages/frontend/src/components/MkFlashPreview.vue @@ -36,7 +36,7 @@ const props = defineProps<{ &:hover { text-decoration: none; - color: var(--accent); + color: var(--MI_THEME-accent); } &:focus-visible { @@ -83,7 +83,6 @@ const props = defineProps<{ > p { display: inline-block; margin: 0; - color: var(--urlPreviewInfo); font-size: 0.8em; line-height: 16px; vertical-align: top; @@ -92,7 +91,7 @@ const props = defineProps<{ } &:global(.gray) { - --c: var(--bg); + --c: var(--MI_THEME-bg); background-image: linear-gradient(45deg, var(--c) 16.67%, transparent 16.67%, transparent 50%, var(--c) 50%, var(--c) 66.67%, transparent 66.67%, transparent 100%); background-size: 16px 16px; } diff --git a/packages/frontend/src/components/MkFoldableSection.vue b/packages/frontend/src/components/MkFoldableSection.vue index f10d58b38a62..fb1b5220fbe6 100644 --- a/packages/frontend/src/components/MkFoldableSection.vue +++ b/packages/frontend/src/components/MkFoldableSection.vue @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -139,15 +140,15 @@ onMounted(() => { width: 100%; box-sizing: border-box; padding: 9px 12px 9px 12px; - background: var(--folderHeaderBg); - -webkit-backdrop-filter: var(--blur, blur(15px)); - backdrop-filter: var(--blur, blur(15px)); + background: var(--MI_THEME-folderHeaderBg); + -webkit-backdrop-filter: var(--MI-blur, blur(15px)); + backdrop-filter: var(--MI-blur, blur(15px)); border-radius: 6px; transition: border-radius 0.3s; &:hover { text-decoration: none; - background: var(--folderHeaderHoverBg); + background: var(--MI_THEME-folderHeaderHoverBg); } &:focus-within { @@ -155,8 +156,8 @@ onMounted(() => { } &.active { - color: var(--accent); - background: var(--folderHeaderHoverBg); + color: var(--MI_THEME-accent); + background: var(--MI_THEME-folderHeaderHoverBg); } &.opened { @@ -170,7 +171,7 @@ onMounted(() => { } .headerLower { - color: var(--fgTransparentWeak); + color: var(--MI_THEME-fgTransparentWeak); font-size: .85em; padding-left: 4px; } @@ -204,13 +205,13 @@ onMounted(() => { } .headerTextSub { - color: var(--fgTransparentWeak); + color: var(--MI_THEME-fgTransparentWeak); font-size: .85em; } .headerRight { margin-left: auto; - color: var(--fgTransparentWeak); + color: var(--MI_THEME-fgTransparentWeak); white-space: nowrap; } @@ -219,26 +220,26 @@ onMounted(() => { } .body { - background: var(--panel); + background: var(--MI_THEME-panel); border-radius: 0 0 6px 6px; container-type: inline-size; &.bgSame { - background: var(--bg); + background: var(--MI_THEME-bg); } } .footer { position: sticky !important; z-index: 1; - bottom: var(--stickyBottom, 0px); + bottom: var(--MI-stickyBottom, 0px); left: 0; padding: 12px; - background: var(--acrylicBg); - -webkit-backdrop-filter: var(--blur, blur(15px)); - backdrop-filter: var(--blur, blur(15px)); + background: var(--MI_THEME-acrylicBg); + -webkit-backdrop-filter: var(--MI-blur, blur(15px)); + backdrop-filter: var(--MI-blur, blur(15px)); background-size: auto auto; - background-image: repeating-linear-gradient(135deg, transparent, transparent 5px, var(--panel) 5px, var(--panel) 10px); + background-image: repeating-linear-gradient(135deg, transparent, transparent 5px, var(--MI_THEME-panel) 5px, var(--MI_THEME-panel) 10px); border-radius: 0 0 6px 6px; } diff --git a/packages/frontend/src/components/MkFollowButton.vue b/packages/frontend/src/components/MkFollowButton.vue index 0de52906ed28..c1dc67f77668 100644 --- a/packages/frontend/src/components/MkFollowButton.vue +++ b/packages/frontend/src/components/MkFollowButton.vue @@ -37,13 +37,13 @@ SPDX-License-Identifier: AGPL-3.0-only + + diff --git a/packages/frontend/src/components/MkGalleryPostPreview.vue b/packages/frontend/src/components/MkGalleryPostPreview.vue index 2bb5b8762a19..22f8355acf1a 100644 --- a/packages/frontend/src/components/MkGalleryPostPreview.vue +++ b/packages/frontend/src/components/MkGalleryPostPreview.vue @@ -75,7 +75,7 @@ function leaveHover(): void { &:hover { text-decoration: none; - color: var(--accent); + color: var(--MI_THEME-accent); > .thumbnail { transform: scale(1.1); diff --git a/packages/frontend/src/components/MkGoogle.vue b/packages/frontend/src/components/MkGoogle.vue index 2988d77fe3cd..2eaee5b11593 100644 --- a/packages/frontend/src/components/MkGoogle.vue +++ b/packages/frontend/src/components/MkGoogle.vue @@ -39,7 +39,7 @@ const search = () => { width: 100%; height: 40px; font-size: 16px; - border: solid 1px var(--divider); + border: solid 1px var(--MI_THEME-divider); border-radius: 4px 0 0 4px; -webkit-appearance: textfield; } @@ -48,7 +48,7 @@ const search = () => { flex-shrink: 0; margin: 0; padding: 0 16px; - border: solid 1px var(--divider); + border: solid 1px var(--MI_THEME-divider); border-left: none; border-radius: 0 4px 4px 0; diff --git a/packages/frontend/src/components/MkInfo.vue b/packages/frontend/src/components/MkInfo.vue index 33e65ccc4e10..90ca1b5a9d04 100644 --- a/packages/frontend/src/components/MkInfo.vue +++ b/packages/frontend/src/components/MkInfo.vue @@ -36,14 +36,14 @@ function close() { align-items: center; padding: 12px 14px; font-size: 90%; - background: var(--infoBg); - color: var(--infoFg); - border-radius: var(--radius); + background: var(--MI_THEME-infoBg); + color: var(--MI_THEME-infoFg); + border-radius: var(--MI-radius); white-space: pre-wrap; &.warn { - background: var(--infoWarnBg); - color: var(--infoWarnFg); + background: var(--MI_THEME-infoWarnBg); + color: var(--MI_THEME-infoWarnFg); } } diff --git a/packages/frontend/src/components/MkInput.vue b/packages/frontend/src/components/MkInput.vue index 4c2fc1ba00da..08817fd6a8fa 100644 --- a/packages/frontend/src/components/MkInput.vue +++ b/packages/frontend/src/components/MkInput.vue @@ -44,7 +44,7 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -78,7 +78,7 @@ function collapsable(v): boolean { > .boolean { display: inline; - color: var(--codeBoolean); + color: var(--MI_THEME-codeBoolean); &.true { font-weight: bold; @@ -91,12 +91,12 @@ function collapsable(v): boolean { > .string { display: inline; - color: var(--codeString); + color: var(--MI_THEME-codeString); } > .number { display: inline; - color: var(--codeNumber); + color: var(--MI_THEME-codeNumber); } > .array.empty { @@ -127,7 +127,7 @@ function collapsable(v): boolean { > .toggle { width: 16px; - color: var(--accent); + color: var(--MI_THEME-accent); visibility: hidden; &.visible { diff --git a/packages/frontend/src/components/MkOmit.vue b/packages/frontend/src/components/MkOmit.vue index ee1f15c18960..a05176e2f461 100644 --- a/packages/frontend/src/components/MkOmit.vue +++ b/packages/frontend/src/components/MkOmit.vue @@ -47,7 +47,7 @@ onUnmounted(() => { @@ -54,7 +54,7 @@ const props = defineProps<{ &:hover { text-decoration: none; - color: var(--accent); + color: var(--MI_THEME-accent); } &:focus-within { @@ -67,22 +67,22 @@ const props = defineProps<{ left: 0; width: 100%; height: 100%; - border-radius: var(--radius); + border-radius: var(--MI-radius); pointer-events: none; - box-shadow: inset 0 0 0 2px var(--focus); + box-shadow: inset 0 0 0 2px var(--MI_THEME-focus); } } > .thumbnail { & + article { - border-radius: 0 0 var(--radius) var(--radius); + border-radius: 0 0 var(--MI-radius) var(--MI-radius); } } > article { - background-color: var(--panel); + background-color: var(--MI_THEME-panel); padding: 16px; - border-radius: var(--radius); + border-radius: var(--MI-radius); > header { margin-bottom: 8px; @@ -115,7 +115,6 @@ const props = defineProps<{ > p { display: inline-block; margin: 0; - color: var(--urlPreviewInfo); font-size: 0.8em; line-height: 16px; vertical-align: top; diff --git a/packages/frontend/src/components/MkPageWindow.vue b/packages/frontend/src/components/MkPageWindow.vue index 2b993ab12f9c..9547423227a6 100644 --- a/packages/frontend/src/components/MkPageWindow.vue +++ b/packages/frontend/src/components/MkPageWindow.vue @@ -13,7 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only :buttonsLeft="buttonsLeft" :buttonsRight="buttonsRight" :contextmenu="contextmenu" - @closed="$emit('closed')" + @closed="emit('closed')" >