diff --git a/locales/ja.yml b/locales/ja.yml index 13ccce048..37d6ab5c4 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -926,6 +926,11 @@ desktop/views/pages/admin/admin.unsuspend-user.vue: unsuspend: "凍結の解除" unsuspended: "凍結を解除しました" +desktop/views/pages/admin/admin.verify-user.vue: + verify-user: "ユーザーの公式アカウント設定" + verify: "公式アカウントにする" + verified: "公式アカウントにしました" + desktop/views/pages/deck/deck.tl-column.vue: is-media-only: "メディア投稿のみ" is-media-view: "メディアビュー" diff --git a/src/client/app/desktop/views/pages/admin/admin.verify-user.vue b/src/client/app/desktop/views/pages/admin/admin.verify-user.vue new file mode 100644 index 000000000..c9a81fae9 --- /dev/null +++ b/src/client/app/desktop/views/pages/admin/admin.verify-user.vue @@ -0,0 +1,51 @@ +<template> +<div> + <header>%i18n:@verify-user%</header> + <input v-model="username" type="text" class="ui"/> + <button class="ui" @click="verifyUser" :disabled="verifying">%i18n:@verify%</button> +</div> +</template> + +<script lang="ts"> +import Vue from "vue"; +import parseAcct from "../../../../../../misc/acct/parse"; + +export default Vue.extend({ + data() { + return { + username: null, + verifying: false + }; + }, + methods: { + async verifyUser() { + this.verifying = true; + + const user = await (this as any).os.api( + "users/show", + parseAcct(this.username) + ); + + await (this as any).os.api("admin/verify-user", { + userId: user.id + }); + + this.verifying = false; + + (this as any).os.apis.dialog({ text: "%i18n:@verified%" }); + } + } +}); +</script> + +<style lang="stylus" scoped> +@import '~const.styl' + +header + margin 10px 0 + + +button + margin 16px 0 + +</style> diff --git a/src/client/app/desktop/views/pages/admin/admin.vue b/src/client/app/desktop/views/pages/admin/admin.vue index b581bea46..29b6093c9 100644 --- a/src/client/app/desktop/views/pages/admin/admin.vue +++ b/src/client/app/desktop/views/pages/admin/admin.vue @@ -15,6 +15,7 @@ <div v-if="page == 'users'"> <x-suspend-user/> <x-unsuspend-user/> + <x-verify-user/> </div> <div v-if="page == 'drive'"></div> <div v-if="page == 'update'"></div> @@ -27,12 +28,14 @@ import Vue from "vue"; import XDashboard from "./admin.dashboard.vue"; import XSuspendUser from "./admin.suspend-user.vue"; import XUnsuspendUser from "./admin.unsuspend-user.vue"; +import XVerifyUser from "./admin.verify-user.vue"; export default Vue.extend({ components: { XDashboard, XSuspendUser, - XUnsuspendUser + XUnsuspendUser, + XVerifyUser }, data() { return { diff --git a/src/server/api/endpoints/admin/verify-user.ts b/src/server/api/endpoints/admin/verify-user.ts new file mode 100644 index 000000000..5b826eb1c --- /dev/null +++ b/src/server/api/endpoints/admin/verify-user.ts @@ -0,0 +1,46 @@ +import $ from 'cafy'; +import ID from '../../../../misc/cafy-id'; +import getParams from '../../get-params'; +import User from '../../../../models/user'; + +export const meta = { + desc: { + ja: '指定したユーザーを公式アカウントにします。', + en: 'Mark a user as verified.' + }, + + requireCredential: true, + requireAdmin: true, + + params: { + userId: $.type(ID).note({ + desc: { + ja: '対象のユーザーID', + en: 'The user ID which you want to verify' + } + }), + } +}; + +export default (params: any) => new Promise(async (res, rej) => { + const [ps, psErr] = getParams(meta, params); + if (psErr) return rej(psErr); + + const user = await User.findOne({ + _id: ps.userId + }); + + if (user == null) { + return rej('user not found'); + } + + await User.findOneAndUpdate({ + _id: user._id + }, { + $set: { + isVerified: true + } + }); + + res(); +});