From 1dc7814151b87c1f8d6b1e3b8b8bb01718df593f Mon Sep 17 00:00:00 2001 From: SushilMallRC Date: Fri, 5 Jul 2024 12:18:05 +0530 Subject: [PATCH] Handle Case when CallLog Creation failed and logId is null --- src/core/log.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/core/log.js b/src/core/log.js index 66caf34f..2e2b3f7f 100644 --- a/src/core/log.js +++ b/src/core/log.js @@ -69,13 +69,15 @@ async function createCallLog({ platform, userId, incomingData }) { name: incomingData.contactName ?? "" }; const { logId, returnMessage } = await platformModule.createCallLog({ user, contactInfo, authHeader, callLog, note, additionalSubmission }); - await CallLogModel.create({ - id: incomingData.logInfo.id, - sessionId: incomingData.logInfo.sessionId, - platform, - thirdPartyLogId: logId, - userId - }); + if (!!logId) { + await CallLogModel.create({ + id: incomingData.logInfo.id, + sessionId: incomingData.logInfo.sessionId, + platform, + thirdPartyLogId: logId, + userId + }); + } return { successful: true, logId, returnMessage }; } catch (e) { console.log(`Error: status: ${e.response?.status}. data: ${e.response?.data}`);