Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix abort callback #1106

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading