mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 21:23:08 +02:00
b9cb6d1c10
将来ESMに移行しやすいように Related: #7658 なんかmochaが起動しなくなってるけど理由不明 すぐ直したい
38 lines
836 B
TypeScript
38 lines
836 B
TypeScript
import define from '../define.js';
|
|
import { fetchMeta } from '@/misc/fetch-meta.js';
|
|
import { DriveFiles } from '@/models/index.js';
|
|
|
|
export const meta = {
|
|
tags: ['drive', 'account'],
|
|
|
|
requireCredential: true as const,
|
|
|
|
kind: 'read:drive',
|
|
|
|
res: {
|
|
type: 'object' as const,
|
|
optional: false as const, nullable: false as const,
|
|
properties: {
|
|
capacity: {
|
|
type: 'number' as const,
|
|
optional: false as const, nullable: false as const,
|
|
},
|
|
usage: {
|
|
type: 'number' as const,
|
|
optional: false as const, nullable: false as const,
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
export default define(meta, async (ps, user) => {
|
|
const instance = await fetchMeta(true);
|
|
|
|
// Calculate drive usage
|
|
const usage = await DriveFiles.calcDriveUsageOf(user.id);
|
|
|
|
return {
|
|
capacity: 1024 * 1024 * instance.localDriveCapacityMb,
|
|
usage: usage
|
|
};
|
|
});
|