diff options
| author | Aya Morisawa <AyaMorisawa4869@gmail.com> | 2018-08-15 06:50:49 +0900 |
|---|---|---|
| committer | Aya Morisawa <AyaMorisawa4869@gmail.com> | 2018-08-15 06:50:49 +0900 |
| commit | c53cb942507a791b098638e085fa1246b5b63f40 (patch) | |
| tree | 8dc6a46710ba596d8e17fd7b6d7cf6208c33aa3a /src/server/api | |
| parent | Merge pull request #2216 from syuilo/patch-2201 (diff) | |
| download | sharkey-c53cb942507a791b098638e085fa1246b5b63f40.tar.gz sharkey-c53cb942507a791b098638e085fa1246b5b63f40.tar.bz2 sharkey-c53cb942507a791b098638e085fa1246b5b63f40.zip | |
Resolve #2215
Diffstat (limited to 'src/server/api')
| -rw-r--r-- | src/server/api/endpoints/admin/unsuspend-user.ts | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/server/api/endpoints/admin/unsuspend-user.ts b/src/server/api/endpoints/admin/unsuspend-user.ts new file mode 100644 index 0000000000..8409bd1b76 --- /dev/null +++ b/src/server/api/endpoints/admin/unsuspend-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: '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(); +}); |