From 8e2be5e9a7c9a851bcdbbd77bf079a40ead598dc Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 14 Oct 2021 01:55:39 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20https://github.com/misskey-dev/misskey?= =?UTF-8?q?/commit/ba6959b8c1c4faafccdeb0f76eb26fc29e02af2d=20=E3=81=AE?= =?UTF-8?q?=E3=83=AA=E3=83=A2=E3=83=BC=E3=83=88=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/api/endpoints/blocking/create.ts | 12 ++++++------ src/services/blocking/create.ts | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/server/api/endpoints/blocking/create.ts b/src/server/api/endpoints/blocking/create.ts index 850406908..4deaa3997 100644 --- a/src/server/api/endpoints/blocking/create.ts +++ b/src/server/api/endpoints/blocking/create.ts @@ -66,10 +66,6 @@ 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); @@ -86,8 +82,12 @@ export default define(meta, async (ps, user) => { throw new ApiError(meta.errors.alreadyBlocking); } - // Create blocking - await create(blocker, blockee); + try { + await create(blocker, blockee); + } catch (e) { + if (e.id === 'e42b7890-5e4d-9d9c-d54b-cf4dd30adfb5') throw new ApiError(meta.errors.cannotBlockModerator); + throw e; + } NoteWatchings.delete({ userId: blocker.id, diff --git a/src/services/blocking/create.ts b/src/services/blocking/create.ts index 76c4bda9d..defe37751 100644 --- a/src/services/blocking/create.ts +++ b/src/services/blocking/create.ts @@ -9,8 +9,13 @@ import { User } from '@/models/entities/user'; import { Blockings, Users, FollowRequests, Followings, UserListJoinings, UserLists } from '@/models/index'; import { perUserFollowingChart } from '@/services/chart/index'; import { genId } from '@/misc/gen-id'; +import { IdentifiableError } from '@/misc/identifiable-error'; export default async function(blocker: User, blockee: User) { + if (blockee.isAdmin || blockee.isModerator) { + throw new IdentifiableError('e42b7890-5e4d-9d9c-d54b-cf4dd30adfb5'); + } + await Promise.all([ cancelRequest(blocker, blockee), cancelRequest(blockee, blocker),