forked from FoundKeyGang/FoundKey
Create find-by-hash.ts
This commit is contained in:
parent
9fac8a611f
commit
d73e52ac2a
1 changed files with 44 additions and 0 deletions
44
src/server/api/endpoints/drive/files/find-by-hash.ts
Normal file
44
src/server/api/endpoints/drive/files/find-by-hash.ts
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
import $ from 'cafy';
|
||||||
|
import define from '../../../define';
|
||||||
|
import { DriveFiles } from '../../../../../models';
|
||||||
|
import { types, bool } from '../../../../../misc/schema';
|
||||||
|
|
||||||
|
export const meta = {
|
||||||
|
desc: {
|
||||||
|
'ja-JP': '与えられたMD5ハッシュ値を持つファイルを取得します。',
|
||||||
|
},
|
||||||
|
|
||||||
|
tags: ['drive'],
|
||||||
|
|
||||||
|
requireCredential: true,
|
||||||
|
|
||||||
|
kind: 'read:drive',
|
||||||
|
|
||||||
|
params: {
|
||||||
|
md5: {
|
||||||
|
validator: $.str,
|
||||||
|
desc: {
|
||||||
|
'ja-JP': 'ファイルのMD5ハッシュ'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
res: {
|
||||||
|
type: types.array,
|
||||||
|
optional: bool.false, nullable: bool.false,
|
||||||
|
items: {
|
||||||
|
type: types.object,
|
||||||
|
optional: bool.false, nullable: bool.false,
|
||||||
|
ref: 'DriveFile',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default define(meta, async (ps, user) => {
|
||||||
|
const files = await DriveFiles.find({
|
||||||
|
md5: ps.md5,
|
||||||
|
userId: user.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
return await DriveFiles.packMany(files, { self: true });
|
||||||
|
});
|
Loading…
Reference in a new issue