From 4f8d97c17b03c9e85f2518d68a2601d8592d617f Mon Sep 17 00:00:00 2001 From: Vijay Date: Tue, 17 Sep 2024 12:26:16 +0530 Subject: [PATCH] fix: from argument in kafka notification for abort --- src/domain/position/abort.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/domain/position/abort.js b/src/domain/position/abort.js index 3fe24f4c4..995de783f 100644 --- a/src/domain/position/abort.js +++ b/src/domain/position/abort.js @@ -83,6 +83,7 @@ const processPositionAbortBin = async ( accumulatedTransferStatesCopy[positionChangeToBeProcessed.transferId] = transferStateId } binItem.result = { success: true } + const from = binItem.message.value.from cyrilResult.positionChanges[positionChangeIndex].isDone = true const nextIndex = cyrilResult.positionChanges.findIndex(positionChange => !positionChange.isDone) if (nextIndex === -1) { @@ -91,11 +92,11 @@ const processPositionAbortBin = async ( for (const positionChange of cyrilResult.positionChanges) { if (positionChange.isFxTransferStateChange) { // Construct notification message for fx transfer state change - const resultMessage = _constructAbortResultMessage(binItem, positionChange.commitRequestId, Config.HUB_NAME, positionChange.notifyTo) + const resultMessage = _constructAbortResultMessage(binItem, positionChange.commitRequestId, from, positionChange.notifyTo) resultMessages.push({ binItem, message: resultMessage }) } else { // Construct notification message for transfer state change - const resultMessage = _constructAbortResultMessage(binItem, positionChange.transferId, Config.HUB_NAME, positionChange.notifyTo) + const resultMessage = _constructAbortResultMessage(binItem, positionChange.transferId, from, positionChange.notifyTo) resultMessages.push({ binItem, message: resultMessage }) } } @@ -127,7 +128,9 @@ const processPositionAbortBin = async ( const _constructAbortResultMessage = (binItem, id, from, notifyTo) => { let apiErrorCode = ErrorHandler.Enums.FSPIOPErrorCodes.PAYEE_REJECTION - if (binItem.message?.value.metadata.event.action === Enum.Events.Event.Action.FX_ABORT_VALIDATION) { + let fromCalculated = from + if (binItem.message?.value.metadata.event.action === Enum.Events.Event.Action.FX_ABORT_VALIDATION || binItem.message?.value.metadata.event.action === Enum.Events.Event.Action.ABORT_VALIDATION) { + fromCalculated = Config.HUB_NAME apiErrorCode = ErrorHandler.Enums.FSPIOPErrorCodes.VALIDATION_ERROR } const fspiopError = ErrorHandler.Factory.createFSPIOPError( @@ -153,8 +156,8 @@ const _constructAbortResultMessage = (binItem, id, from, notifyTo) => { ) const resultMessage = Utility.StreamingProtocol.createMessage( id, - from, notifyTo, + fromCalculated, metadata, binItem.message.value.content.headers, // Headers don't really matter here. ml-api-adapter will ignore them and create their own. fspiopError,