From 3abebba2455012c9c6a0e185881f7ad4c8aa90b6 Mon Sep 17 00:00:00 2001 From: cutestnekoaqua Date: Mon, 12 Dec 2022 02:17:07 +0100 Subject: [PATCH] Add admin and account locked error. --- packages/backend/src/server/api/endpoints/i/move.ts | 6 ++++++ packages/backend/src/server/api/endpoints/notes/create.ts | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/i/move.ts b/packages/backend/src/server/api/endpoints/i/move.ts index e6bd03601..562d35007 100644 --- a/packages/backend/src/server/api/endpoints/i/move.ts +++ b/packages/backend/src/server/api/endpoints/i/move.ts @@ -35,6 +35,11 @@ export const meta = { code: 'NOT_REMOTE', id: '4362f8dc-731f-4ad8-a694-be2a88922a24', }, + adminForbidden: { + message: 'Adminds cant migrate.', + code: 'NOT_ADMIN_FORBIDDEN', + id: '4362e8dc-731f-4ad8-a694-be2a88922a24', + }, }, } as const; @@ -49,6 +54,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, user) => { if (!ps.moveToAccount) throw new ApiError(meta.errors.noSuchMoveTarget); + if(user.isAdmin) throw new ApiError(meta.errors.adminForbidden); let unfiltered: string = ps.moveToAccount; diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index da34f3c8d..68c04ff22 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -78,6 +78,12 @@ export const meta = { code: 'YOU_HAVE_BEEN_BLOCKED', id: 'b390d7e1-8a5e-46ed-b625-06271cafd3d3', }, + + accountLocked: { + message: 'You migrated. Your account is now locked.', + code: 'ACCOUNT_LOCKED', + id: 'd390d7e1-8a5e-46ed-b625-06271cafd3d3', + }, }, } as const; @@ -163,6 +169,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, user) => { + if(user.movedToUri) throw new ApiError(meta.errors.accountLocked); let visibleUsers: User[] = []; if (ps.visibleUserIds) { visibleUsers = await Users.findBy({