From 061fd71e1ebf8e34d1e08d2c5b2d90f8582624b2 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Fri, 27 Jan 2023 11:57:15 +0000 Subject: [PATCH] hashing reps and submission blobs --- actions/index.js | 9 +++-- .../api/file/getawaitingsubmissionfromblob.js | 24 ++++++------- pages/api/file/getrepsblob.js | 36 +++++++------------ 3 files changed, 32 insertions(+), 37 deletions(-) diff --git a/actions/index.js b/actions/index.js index 0f439d7c..563edd11 100644 --- a/actions/index.js +++ b/actions/index.js @@ -795,10 +795,11 @@ export const getAwaitingSubmissionFromBlob = (containerName) => { export const getRepsFromBlob = (containerName) => { console.log( - "///////////////////////getRepsFromBlob: " + + "///////////////////////\ngetRepsFromBlob: " + containerName + "\n///////////////////////\n" ); + return axios .get( BASE_URL + @@ -819,7 +820,11 @@ export const getAwaitingSubmissionFromBlobProxy = (containerName) => { .get( BASE_URL + "/api/file/getawaitingsubmissionfromblob?container=" + - containerName + containerName + + +hashAPIPath( + "/api/file/getawaitingsubmissionfromblob?container=" + + containerName + ) ) .then((res) => { return res.data; diff --git a/pages/api/file/getawaitingsubmissionfromblob.js b/pages/api/file/getawaitingsubmissionfromblob.js index 18188a17..085eb474 100644 --- a/pages/api/file/getawaitingsubmissionfromblob.js +++ b/pages/api/file/getawaitingsubmissionfromblob.js @@ -23,19 +23,19 @@ ApiProxy.get(async (req, res) => { "\n///////////////////////\n" ); // console.log(hashAPIPath(checkquerypath), checkHash); - // console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); + //console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); - //if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { - const blobObj = await getAllProgressBlobs(containerName) - .then((data) => { - return downloadAllProgressFiles(containerName, data); - }) - .then((data) => { - return res.status(200).json(data); - }); - // } else { - // return res.status(400).json(); - // } + if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { + const blobObj = await getAllProgressBlobs(containerName) + .then((data) => { + return downloadAllProgressFiles(containerName, data); + }) + .then((data) => { + return res.status(200).json(data); + }); + } else { + return res.status(400).json(); + } }); export const config = { diff --git a/pages/api/file/getrepsblob.js b/pages/api/file/getrepsblob.js index 215b12ce..3c2823fb 100644 --- a/pages/api/file/getrepsblob.js +++ b/pages/api/file/getrepsblob.js @@ -5,6 +5,7 @@ import { import _ from "lodash"; import nextConnect from "next-connect"; import middleware from "../middleware/middleware"; +import { hashAPIPath } from "../../../actions"; const ApiProxy = nextConnect(); ApiProxy.use(middleware); @@ -14,30 +15,19 @@ ApiProxy.get(async (req, res) => { var casefolderID = req.query.casefolderID; var checkHash = req.query.hash; - var checkquerypath = - "/api/file/getrepsblob?container=" + - containerName + - "&casefolderID=" + - casefolderID; + var checkquerypath = "/api/file/getrepsblob?container=" + containerName; - console.log(checkquerypath); - // console.log(hashAPIPath(checkquerypath), checkHash); - // console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); - - //if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { - const blobObj = await getRepslobs(containerName, casefolderID) - .then((data) => { - console.log("reps blob", data); - - return downloadAllRepsFiles(containerName, data); - }) - .then((data) => { - return res.status(200).json(data); - }); - - // } else { - // return res.status(400).json(); - // } + if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { + const blobObj = await getRepslobs(containerName, casefolderID) + .then((data) => { + return downloadAllRepsFiles(containerName, data); + }) + .then((data) => { + return res.status(200).json(data); + }); + } else { + return res.status(400).json(); + } }); export const config = {