Sharkey/src/server/api/endpoints/drive/files/check_existence.ts
syuilo 52774bbe64
Introduce OpenAPI specs (#4351)
* 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
2019-02-23 11:20:58 +09:00

35 lines
822 B
TypeScript

import $ from 'cafy';
import DriveFile, { pack } from '../../../../../models/drive-file';
import define from '../../../define';
export const meta = {
desc: {
'ja-JP': '与えられたMD5ハッシュ値を持つファイルがドライブに存在するかどうかを返します。',
'en-US': 'Returns whether the file with the given MD5 hash exists in the user\'s drive.'
},
tags: ['drive'],
requireCredential: true,
kind: 'drive-read',
params: {
md5: {
validator: $.str,
desc: {
'ja-JP': 'ファイルのMD5ハッシュ'
}
}
}
};
export default define(meta, async (ps, user) => {
const file = await DriveFile.findOne({
md5: ps.md5,
'metadata.userId': user._id,
'metadata.deletedAt': { $exists: false }
});
return { file: file ? await pack(file, { self: true }) : null };
});