[FEATURE] Move Files Protocol
This commit is contained in:
parent
39369fe41a
commit
c9361e6771
7 changed files with 52 additions and 79 deletions
|
@ -4,6 +4,7 @@ import {
|
|||
listServerFiles,
|
||||
removeServerItem,
|
||||
uploadServerItem,
|
||||
moveServerItems,
|
||||
} from "../k8s/server-files.js";
|
||||
import { sendError } from "../util/ExpressClientError.js";
|
||||
import { checkAuthorization } from "../database/queries/server-queries.js";
|
||||
|
@ -79,3 +80,18 @@ export async function getItem(req, res) {
|
|||
})
|
||||
.catch(sendError(res));
|
||||
}
|
||||
|
||||
export async function moveItems(req, res) {
|
||||
const serverSpec = req.body;
|
||||
if (!serverSpec.id) return res.status(400).send("Server id missing!");
|
||||
if (!serverSpec.destination)
|
||||
return res.status(400).send("Destination required!");
|
||||
if (!serverSpec.origin) return res.status(400).send("Origin required!");
|
||||
if (!serverSpec.files || !Array.isArray(serverSpec.files))
|
||||
return res.status(400).send("Files required!");
|
||||
const authorized = await checkAuthorization(serverSpec.id, req.cairoId);
|
||||
if (!authorized) return res.sendStatus(403);
|
||||
moveServerItems(serverSpec)
|
||||
.then(() => res.sendStatus(200))
|
||||
.catch(sendError(res));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue