From 7df9cf00ebcb7c6ab35c7a6502f0c9060bc91b71 Mon Sep 17 00:00:00 2001 From: "priyanka@TL" Date: Mon, 19 Feb 2024 11:22:10 +0530 Subject: [PATCH 1/2] fix for undefined in get signed url --- src/controllers/v1/cloud-services.js | 2 +- src/services/files.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/v1/cloud-services.js b/src/controllers/v1/cloud-services.js index b9803d161..d518a85c8 100644 --- a/src/controllers/v1/cloud-services.js +++ b/src/controllers/v1/cloud-services.js @@ -18,7 +18,7 @@ module.exports = class CloudServices { try { const signedUrlResponse = await filesService.getSignedUrl( req.query.fileName, - req.decodedToken._id, + req.decodedToken.id, req.query.dynamicPath ? req.query.dynamicPath : '' ) return signedUrlResponse diff --git a/src/services/files.js b/src/services/files.js index 4bca3af5e..cad0c4a26 100644 --- a/src/services/files.js +++ b/src/services/files.js @@ -5,13 +5,13 @@ const utils = require('@generics/utils') const responses = require('@helpers/responses') module.exports = class FilesHelper { - static async getSignedUrl(fileName, _id, dynamicPath) { + static async getSignedUrl(fileName, id, dynamicPath) { try { let destFilePath if (dynamicPath != '') { destFilePath = dynamicPath + '/' + fileName } else { - destFilePath = `session/${_id}-${new Date().getTime()}-${fileName}` + destFilePath = `session/${id}-${new Date().getTime()}-${fileName}` } let response if (process.env.CLOUD_STORAGE === 'GCP') { From bf7de8c3fbd2b23f3e699a6c73fc11198cc7c106 Mon Sep 17 00:00:00 2001 From: "priyanka@TL" Date: Mon, 19 Feb 2024 12:55:30 +0530 Subject: [PATCH 2/2] check for session creation --- src/services/sessions.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/services/sessions.js b/src/services/sessions.js index 9b897d1d2..63c5c5515 100644 --- a/src/services/sessions.js +++ b/src/services/sessions.js @@ -212,6 +212,14 @@ module.exports = class SessionsHelper { // Create session const data = await sessionQueries.create(bodyData) + if (!data?.id) { + return responses.failureResponse({ + message: 'SESSION_CREATION_FAILED', + statusCode: httpStatusCode.bad_request, + responseCode: 'CLIENT_ERROR', + result: res.errors, + }) + } // If menteeIds are provided in the req body enroll them if (menteeIdsToEnroll.length > 0) { await this.addMentees(data.id, menteeIdsToEnroll, bodyData.time_zone)