mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 20:53:08 +02:00
cd07eb222e
* Add additional drive capacity change support
* Update packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts
Co-authored-by: Johann150 <johann@qwertqwefsday.eu>
* 🎨
* show instance default capacity in placeholder
* fix
* update api/drive
* fix
* remove :
* fix lint
Co-authored-by: Johann150 <johann@qwertqwefsday.eu>
Co-authored-by: tamaina <tamaina@hotmail.co.jp>
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import define from '../../define.js';
|
|
import { Users } from '@/models/index.js';
|
|
import { User } from '@/models/entities/user.js';
|
|
import { insertModerationLog } from '@/services/insert-moderation-log.js';
|
|
export const meta = {
|
|
tags: ['admin'],
|
|
|
|
requireCredential: true,
|
|
requireModerator: true,
|
|
} as const;
|
|
|
|
export const paramDef = {
|
|
type: 'object',
|
|
properties: {
|
|
userId: { type: 'string', format: 'misskey:id' },
|
|
overrideMb: { type: 'number', nullable: true },
|
|
},
|
|
required: ['userId', 'overrideMb'],
|
|
} as const;
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
export default define(meta, paramDef, async (ps, me) => {
|
|
const user = await Users.findOneBy({ id: ps.userId });
|
|
|
|
if (user == null) {
|
|
throw new Error('user not found');
|
|
}
|
|
|
|
if (!Users.isLocalUser(user)) {
|
|
throw new Error('user is not local user');
|
|
}
|
|
|
|
/*if (user.isAdmin) {
|
|
throw new Error('cannot suspend admin');
|
|
}
|
|
if (user.isModerator) {
|
|
throw new Error('cannot suspend moderator');
|
|
}*/
|
|
|
|
await Users.update(user.id, {
|
|
driveCapacityOverrideMb: ps.overrideMb,
|
|
});
|
|
|
|
insertModerationLog(me, 'change-drive-capacity-override', {
|
|
targetId: user.id,
|
|
});
|
|
});
|