52774bbe64
* wip * wip * wip * Update index.ts * Update gen-openapi-spec.ts * Update api.ja-JP.md * Fix * Improve doc * Update gen-openapi-spec.ts * Update redoc.html * Improve doc * Update gen-openapi-spec.ts * Improve doc * Update CHANGELOG.md
39 lines
759 B
TypeScript
39 lines
759 B
TypeScript
import $ from 'cafy';
|
|
import ID, { transform } from '../../../../../misc/cafy-id';
|
|
import DriveFile, { pack } from '../../../../../models/drive-file';
|
|
import define from '../../../define';
|
|
|
|
export const meta = {
|
|
requireCredential: true,
|
|
|
|
tags: ['drive'],
|
|
|
|
kind: 'drive-read',
|
|
|
|
params: {
|
|
name: {
|
|
validator: $.str
|
|
},
|
|
|
|
folderId: {
|
|
validator: $.optional.nullable.type(ID),
|
|
transform: transform,
|
|
default: null as any,
|
|
desc: {
|
|
'ja-JP': 'フォルダID'
|
|
}
|
|
},
|
|
}
|
|
};
|
|
|
|
export default define(meta, async (ps, user) => {
|
|
const files = await DriveFile
|
|
.find({
|
|
filename: ps.name,
|
|
'metadata.userId': user._id,
|
|
'metadata.folderId': ps.folderId
|
|
});
|
|
|
|
return await Promise.all(files.map(file => pack(file, { self: true })));
|
|
});
|