Skip to content

Commit

Permalink
fix: fix abort callback (#1106)
Browse files Browse the repository at this point in the history
fix: from argument in kafka notification for abort
  • Loading branch information
vijayg10 authored Sep 17, 2024
1 parent 3182803 commit b6e9e2b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/domain/position/abort.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 })
}
}
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down

0 comments on commit b6e9e2b

Please sign in to comment.