Merge pull request #2219 from syuilo/patch-2215

Resolve #2215
This commit is contained in:
syuilo 2018-08-15 11:07:07 +09:00 committed by GitHub
commit 6aa5c5895f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 106 additions and 1 deletions

View file

@ -915,6 +915,11 @@ desktop/views/pages/admin/admin.suspend-user.vue:
suspend: "凍結" suspend: "凍結"
suspended: "凍結しました" suspended: "凍結しました"
desktop/views/pages/admin/admin.unsuspend-user.vue:
unsuspend-user: "ユーザーの凍結の解除"
unsuspend: "凍結の解除"
unsuspended: "凍結を解除しました"
desktop/views/pages/deck/deck.tl-column.vue: desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ" is-media-only: "メディア投稿のみ"
is-media-view: "メディアビュー" is-media-view: "メディアビュー"

View file

@ -0,0 +1,51 @@
<template>
<div>
<header>%i18n:@unsuspend-user%</header>
<input v-model="username" type="text" class="ui"/>
<button class="ui" @click="unsuspendUser" :disabled="unsuspending">%i18n:@unsuspend%</button>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import parseAcct from "../../../../../../misc/acct/parse";
export default Vue.extend({
data() {
return {
username: null,
unsuspending: false
};
},
methods: {
async unsuspendUser() {
this.unsuspending = true;
const user = await (this as any).os.api(
"users/show",
parseAcct(this.username)
);
await (this as any).os.api("admin/unsuspend-user", {
userId: user.id
});
this.unsuspending = false;
(this as any).os.apis.dialog({ text: "%i18n:@unsuspended%" });
}
}
});
</script>
<style lang="stylus" scoped>
@import '~const.styl'
header
margin 10px 0
button
margin 16px 0
</style>

View file

@ -14,6 +14,7 @@
</div> </div>
<div v-if="page == 'users'"> <div v-if="page == 'users'">
<x-suspend-user/> <x-suspend-user/>
<x-unsuspend-user/>
</div> </div>
<div v-if="page == 'drive'"></div> <div v-if="page == 'drive'"></div>
<div v-if="page == 'update'"></div> <div v-if="page == 'update'"></div>
@ -25,11 +26,13 @@
import Vue from "vue"; import Vue from "vue";
import XDashboard from "./admin.dashboard.vue"; import XDashboard from "./admin.dashboard.vue";
import XSuspendUser from "./admin.suspend-user.vue"; import XSuspendUser from "./admin.suspend-user.vue";
import XUnsuspendUser from "./admin.unsuspend-user.vue";
export default Vue.extend({ export default Vue.extend({
components: { components: {
XDashboard, XDashboard,
XSuspendUser XSuspendUser,
XUnsuspendUser
}, },
data() { data() {
return { return {

View file

@ -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: 'Unsuspend a user.'
},
requireCredential: true,
requireAdmin: true,
params: {
userId: $.type(ID).note({
desc: {
ja: '対象のユーザーID',
en: 'The user ID which you want to unsuspend'
}
}),
}
};
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: {
isSuspended: false
}
});
res();
});