Add admin and account locked error.

This commit is contained in:
cutestnekoaqua 2022-12-12 02:17:07 +01:00
parent f9615f233f
commit d613c5d9de
2 changed files with 13 additions and 0 deletions

View File

@ -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;

View File

@ -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({