mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 13:23:09 +02:00
36 lines
765 B
TypeScript
36 lines
765 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,
|
|
|
|
kind: 'drive-read',
|
|
|
|
params: {
|
|
name: {
|
|
validator: $.str
|
|
},
|
|
|
|
folderId: {
|
|
validator: $.type(ID).optional.nullable,
|
|
transform: transform,
|
|
default: null as any,
|
|
desc: {
|
|
'ja-JP': 'フォルダID'
|
|
}
|
|
},
|
|
}
|
|
};
|
|
|
|
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
|
const files = await DriveFile
|
|
.find({
|
|
filename: ps.name,
|
|
'metadata.userId': user._id,
|
|
'metadata.folderId': ps.folderId
|
|
});
|
|
|
|
res(await Promise.all(files.map(file => pack(file, { self: true }))));
|
|
}));
|