Skip to content

Commit

Permalink
fix(api): 管理者およびモデレーターをブロックできてしまう問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Oct 13, 2021
1 parent 91c9a63 commit ba6959b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- クライアント: ヘッダーのタブが折り返される問題を修正
- クライアント: ヘッダーにタブが表示されている状態でタイトルをクリックしたときにタブ選択が表示されるのを修正
- クライアント: ユーザーページのタブが機能していない問題を修正
- API: 管理者およびモデレーターをブロックできてしまう問題を修正

## 12.91.0 (2021/09/22)

Expand Down
10 changes: 10 additions & 0 deletions src/server/api/endpoints/blocking/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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);
Expand Down

0 comments on commit ba6959b

Please sign in to comment.