2018-11-01 22:47:44 -06:00
|
|
|
import define from '../define';
|
2019-04-23 17:11:19 -06:00
|
|
|
import { fetchMeta } from '../../../misc/fetch-meta';
|
2019-04-07 06:50:36 -06:00
|
|
|
import { DriveFiles } from '../../../models';
|
2019-04-23 07:35:26 -06:00
|
|
|
import { types, bool } from '../../../misc/schema';
|
2016-12-28 15:49:51 -07:00
|
|
|
|
2018-07-16 13:36:44 -06:00
|
|
|
export const meta = {
|
|
|
|
desc: {
|
2018-08-28 15:59:43 -06:00
|
|
|
'ja-JP': 'ドライブの情報を取得します。',
|
|
|
|
'en-US': 'Get drive information.'
|
2018-07-16 13:36:44 -06:00
|
|
|
},
|
|
|
|
|
2019-02-22 19:20:58 -07:00
|
|
|
tags: ['drive', 'account'],
|
|
|
|
|
2018-07-16 13:36:44 -06:00
|
|
|
requireCredential: true,
|
|
|
|
|
2019-04-07 06:50:36 -06:00
|
|
|
kind: 'read:drive',
|
2019-02-24 11:21:54 -07:00
|
|
|
|
|
|
|
res: {
|
2019-04-23 07:35:26 -06:00
|
|
|
type: types.object,
|
|
|
|
optional: bool.false, nullable: bool.false,
|
2019-02-24 11:21:54 -07:00
|
|
|
properties: {
|
|
|
|
capacity: {
|
2019-04-23 07:35:26 -06:00
|
|
|
type: types.number,
|
|
|
|
optional: bool.false, nullable: bool.false,
|
2019-02-24 11:21:54 -07:00
|
|
|
},
|
|
|
|
usage: {
|
2019-04-23 07:35:26 -06:00
|
|
|
type: types.number,
|
|
|
|
optional: bool.false, nullable: bool.false,
|
2019-02-24 11:21:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-16 13:36:44 -06:00
|
|
|
};
|
|
|
|
|
2019-02-21 19:46:58 -07:00
|
|
|
export default define(meta, async (ps, user) => {
|
2019-04-23 17:11:19 -06:00
|
|
|
const instance = await fetchMeta(true);
|
2018-11-05 15:14:43 -07:00
|
|
|
|
2017-03-03 12:28:38 -07:00
|
|
|
// Calculate drive usage
|
2019-04-07 06:50:36 -06:00
|
|
|
const usage = await DriveFiles.clacDriveUsageOf(user);
|
2016-12-28 15:49:51 -07:00
|
|
|
|
2019-02-21 19:46:58 -07:00
|
|
|
return {
|
2018-11-05 15:14:43 -07:00
|
|
|
capacity: 1024 * 1024 * instance.localDriveCapacityMb,
|
2017-03-03 12:28:38 -07:00
|
|
|
usage: usage
|
2019-02-21 19:46:58 -07:00
|
|
|
};
|
|
|
|
});
|