fix(api): 管理者およびモデレーターをブロックできてしまう問題を修正

This commit is contained in:
syuilo 2021-10-14 01:24:54 +09:00
parent 91c9a6390c
commit ba6959b8c1
2 changed files with 11 additions and 0 deletions

View file

@ -43,6 +43,12 @@ export const meta = {
code: 'ALREADY_BLOCKING',
id: '787fed64-acb9-464a-82eb-afbd745b9614'
},
cannotBlockModerator: {
message: 'Cannot block a moderator or an admin.',
code: 'CANNOT_BLOCK_MODERATOR',
id: '8544aaef-89fb-e470-9f6c-385d38b474f5'
}
},
res: {
@ -60,6 +66,10 @@ export default define(meta, async (ps, user) => {
throw new ApiError(meta.errors.blockeeIsYourself);
}
if (user.isAdmin || user.isModerator) {
throw new ApiError(meta.errors.cannotBlockModerator);
}
// Get blockee
const blockee = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);