import $ from 'cafy'; import { ID } from '../../../../../misc/cafy-id'; import define from '../../../define'; import { ApiError } from '../../../error'; import { DriveFolders } from '../../../../../models'; import { types, bool } from '../../../../../misc/schema'; export const meta = { stability: 'stable', desc: { 'ja-JP': '指定したドライブのフォルダの情報を取得します。', 'en-US': 'Get specified folder of drive.' }, tags: ['drive'], requireCredential: true, kind: 'read:drive', params: { folderId: { validator: $.type(ID), desc: { 'ja-JP': '対象のフォルダID', 'en-US': 'Target folder ID' } } }, res: { type: types.object, optional: bool.false, nullable: bool.false, ref: 'DriveFolder', }, errors: { noSuchFolder: { message: 'No such folder.', code: 'NO_SUCH_FOLDER', id: 'd74ab9eb-bb09-4bba-bf24-fb58f761e1e9' }, } }; export default define(meta, async (ps, user) => { // Get folder const folder = await DriveFolders.findOne({ id: ps.folderId, userId: user.id }); if (folder == null) { throw new ApiError(meta.errors.noSuchFolder); } return await DriveFolders.pack(folder, { detail: true }); });