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