From 01fab09683db94bb79ae347060d76923f2617a6e Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 19 May 2019 20:43:33 +0900 Subject: [PATCH] Fix #4945 --- src/server/api/endpoints/users/groups/pull.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/server/api/endpoints/users/groups/pull.ts b/src/server/api/endpoints/users/groups/pull.ts index 5fc0c2fa5..3943560d7 100644 --- a/src/server/api/endpoints/users/groups/pull.ts +++ b/src/server/api/endpoints/users/groups/pull.ts @@ -42,7 +42,13 @@ export const meta = { message: 'No such user.', code: 'NO_SUCH_USER', id: '0b5cc374-3681-41da-861e-8bc1146f7a55' - } + }, + + isOwner: { + message: 'The user is the owner.', + code: 'IS_OWNER', + id: '1546eed5-4414-4dea-81c1-b0aec4f6d2af' + }, } }; @@ -63,6 +69,10 @@ export default define(meta, async (ps, me) => { throw e; }); + if (user.id === userGroup.userId) { + throw new ApiError(meta.errors.isOwner); + } + // Pull the user await UserGroupJoinings.delete({ userId: user.id }); });