mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 12:13:08 +02:00
2470afaa2e
* wip * Update CHANGELOG.md * wip * wip * wip * Update create.ts * wip * wip * Update CHANGELOG.md * wip * wip * wip * wip * wip * wip * wip * Update CHANGELOG.md * wip * wip * Update delete.ts * Update delete.ts * wip * wip * wip * Update account-info.vue * wip * wip * Update settings.vue * Update user-info.vue * wip * Update show-file.ts * Update show-user.ts * wip * wip * Update delete.ts * wip * wip * Update overview.moderators.vue * Create 1673500412259-Role.js * wip * wip * Update roles.vue * 色 * Update roles.vue * integrate silence * wip * wip
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import { Inject, Injectable } from '@nestjs/common';
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
|
import { MetaService } from '@/core/MetaService.js';
|
|
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
|
import { RoleService } from '@/core/RoleService.js';
|
|
|
|
export const meta = {
|
|
tags: ['drive', 'account'],
|
|
|
|
requireCredential: true,
|
|
|
|
kind: 'read:drive',
|
|
|
|
res: {
|
|
type: 'object',
|
|
optional: false, nullable: false,
|
|
properties: {
|
|
capacity: {
|
|
type: 'number',
|
|
optional: false, nullable: false,
|
|
},
|
|
usage: {
|
|
type: 'number',
|
|
optional: false, nullable: false,
|
|
},
|
|
},
|
|
},
|
|
} as const;
|
|
|
|
export const paramDef = {
|
|
type: 'object',
|
|
properties: {},
|
|
required: [],
|
|
} as const;
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
@Injectable()
|
|
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|
constructor(
|
|
private metaService: MetaService,
|
|
private driveFileEntityService: DriveFileEntityService,
|
|
private roleService: RoleService,
|
|
) {
|
|
super(meta, paramDef, async (ps, me) => {
|
|
const instance = await this.metaService.fetch(true);
|
|
|
|
// Calculate drive usage
|
|
const usage = await this.driveFileEntityService.calcDriveUsageOf(me.id);
|
|
|
|
const myRole = await this.roleService.getUserRoleOptions(me.id);
|
|
|
|
return {
|
|
capacity: 1024 * 1024 * myRole.driveCapacityMb,
|
|
usage: usage,
|
|
};
|
|
});
|
|
}
|
|
}
|