42 lines
912 B
JavaScript
42 lines
912 B
JavaScript
import { DriveFiles } from "../../../../../models/index.js";
|
|
import define from "../../../define.js";
|
|
export const meta = {
|
|
tags: [
|
|
"drive"
|
|
],
|
|
requireCredential: true,
|
|
kind: "read:drive",
|
|
description: "Search for a drive file by a hash of the contents.",
|
|
res: {
|
|
type: "array",
|
|
optional: false,
|
|
nullable: false,
|
|
items: {
|
|
type: "object",
|
|
optional: false,
|
|
nullable: false,
|
|
ref: "DriveFile"
|
|
}
|
|
}
|
|
};
|
|
export const paramDef = {
|
|
type: "object",
|
|
properties: {
|
|
md5: {
|
|
type: "string"
|
|
}
|
|
},
|
|
required: [
|
|
"md5"
|
|
]
|
|
};
|
|
export default define(meta, paramDef, async (ps, user)=>{
|
|
const files = await DriveFiles.findBy({
|
|
md5: ps.md5,
|
|
userId: user.id
|
|
});
|
|
return await DriveFiles.packMany(files, {
|
|
self: true
|
|
});
|
|
});
|