From 2da90e7241d2f88390a7713e76a86f26e158248e Mon Sep 17 00:00:00 2001 From: atsu1125 Date: Tue, 3 Jan 2023 23:36:33 +0900 Subject: [PATCH] Feat: Revoke Invitation Codes --- locales/en-US.yml | 2 ++ locales/ja-JP.yml | 2 ++ src/client/pages/instance/settings.vue | 18 ++++++++++++++++- .../api/endpoints/admin/invite-revoke.ts | 20 +++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/server/api/endpoints/admin/invite-revoke.ts diff --git a/locales/en-US.yml b/locales/en-US.yml index cd84f74fdb..9630d85d29 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -873,6 +873,8 @@ showVoteConfirm: "Show confirmation dialog before voting" voteConfirm: "Are you sure that you want to vote?" deleteAccount: "Delete Account" deleteAccountConfirm: "Are you sure that you want to delete this account?" +inviteRevoke: "Revoke All Invitation Codes" +inviteRevokeConfirm: "Are you sure that you want to revoke all invitation codes?" _template: edit: "Edit Template..." diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 0bdcbbec47..9f6a792dfe 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -910,6 +910,8 @@ showVoteConfirm: "投票する前に確認ダイアログを表示する" voteConfirm: "投票しますか?" deleteAccount: "アカウント削除" deleteAccountConfirm: "本当にこのアカウントを削除しますか?" +inviteRevoke: "全ての招待コードを失効する" +inviteRevokeConfirm: "本当に全ての招待コードを失効させますか?" _template: edit: "定型文を編集…" diff --git a/src/client/pages/instance/settings.vue b/src/client/pages/instance/settings.vue index 3949566961..34cd9c1c4f 100644 --- a/src/client/pages/instance/settings.vue +++ b/src/client/pages/instance/settings.vue @@ -61,7 +61,8 @@ {{ $ts.disableInvitationReason }} {{ $ts.save }} - {{ $ts.invite }} + {{ $ts.invite }} + {{ $ts.inviteRevoke }} @@ -504,6 +505,21 @@ export default defineComponent({ }); }, + inviteRevoke() { + os.api('admin/invite-revoke').then(x => { + os.dialog({ + type: 'warning', + showCancelButton: true, + text: this.$ts.inviteRevokeConfirm, + }); + }).then(({ canceled }) => { + os.dialog({ + type: 'error', + text: e + }); + }); + }, + addPinUser() { os.selectUser().then(user => { this.pinnedUsers = this.pinnedUsers.trim(); diff --git a/src/server/api/endpoints/admin/invite-revoke.ts b/src/server/api/endpoints/admin/invite-revoke.ts new file mode 100644 index 0000000000..abca4ce03e --- /dev/null +++ b/src/server/api/endpoints/admin/invite-revoke.ts @@ -0,0 +1,20 @@ +import define from '../../define'; +import { RegistrationTickets } from '../../../../models'; + +export const meta = { + desc: { + 'ja-JP': '招待コードを失効します。' + }, + + tags: ['admin'], + + requireCredential: true as const, + requireModerator: true, + + params: {} +}; + +export default define(meta, async () => { + await RegistrationTickets.delete({ + }); +});