2019-01-19 09:50:38 +09:00
|
|
|
import $ from 'cafy';
|
|
|
|
import ID, { transform } from '../../../../../misc/cafy-id';
|
|
|
|
import define from '../../../define';
|
|
|
|
import DriveFile from '../../../../../models/drive-file';
|
2019-02-22 11:46:58 +09:00
|
|
|
import { ApiError } from '../../../error';
|
2019-01-19 09:50:38 +09:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
requireCredential: true,
|
|
|
|
requireModerator: true,
|
|
|
|
|
|
|
|
params: {
|
|
|
|
fileId: {
|
|
|
|
validator: $.type(ID),
|
|
|
|
transform: transform,
|
|
|
|
},
|
2019-02-22 11:46:58 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
errors: {
|
|
|
|
noSuchFile: {
|
|
|
|
message: 'No such file.',
|
|
|
|
code: 'NO_SUCH_FILE',
|
|
|
|
id: 'caf3ca38-c6e5-472e-a30c-b05377dcc240'
|
|
|
|
}
|
2019-01-19 09:50:38 +09:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-02-22 11:46:58 +09:00
|
|
|
export default define(meta, async (ps, me) => {
|
2019-01-19 09:50:38 +09:00
|
|
|
const file = await DriveFile.findOne({
|
|
|
|
_id: ps.fileId
|
|
|
|
});
|
|
|
|
|
|
|
|
if (file == null) {
|
2019-02-22 11:46:58 +09:00
|
|
|
throw new ApiError(meta.errors.noSuchFile);
|
2019-01-19 09:50:38 +09:00
|
|
|
}
|
|
|
|
|
2019-02-22 11:46:58 +09:00
|
|
|
return file;
|
|
|
|
});
|