Skip to content

Commit

Permalink
fix(submit): surpress fulfillment double response
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerald Baulig committed Feb 28, 2025
1 parent b3c64b0 commit 30535e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cfg/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,15 @@
},
"errors": {
"INVALID_CREDENTIALS": {
"code": "401",
"code": 401,
"message": "Invalid credentials"
},
"USER_NOT_LOGGED_IN": {
"code": "401",
"code": 401,
"message": "Invalid authentication context, please log in first"
},
"ACTION_NOT_ALLOWED": {
"code": "403",
"code": 403,
"message": "Action not allowed on this resource"
}
},
Expand Down
12 changes: 5 additions & 7 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,6 @@ export class OrderingService
try {
if (this.fulfillment_service) {
this.logger?.debug('Evaluate fulfillment on submit...');
response.fulfillments = [];
const fulfillment_map: Record<string, FulfillmentResponse> = {};
await this._evaluateFulfillment(
{
Expand All @@ -1534,13 +1533,12 @@ export class OrderingService
r => {
r.items?.forEach(
fulfillment => {
const id = fulfillment.payload?.references?.[0]?.instance_id
?? fulfillment.status?.id;
const id = fulfillment.payload?.references?.[0]?.instance_id;
const order = response_map[id];
if (order && fulfillment.status?.code !== 200) {
order.status = fulfillment.status;
}
fulfillment_map[id] =fulfillment;
fulfillment_map[id] = fulfillment;
}
);

Expand All @@ -1559,7 +1557,7 @@ export class OrderingService
throw error;
}
).finally(
() => response.fulfillments.push(...Object.values(fulfillment_map))
() => response.fulfillments = Object.values(fulfillment_map)
);

this.logger?.debug('Create fulfillment on submit...');
Expand All @@ -1583,7 +1581,7 @@ export class OrderingService
r => {
r.items?.forEach(
fulfillment => {
const id = fulfillment.payload?.references?.[0]?.instance_id ?? fulfillment.status?.id;
const id = fulfillment.payload?.references?.[0]?.instance_id;
const order = response_map[id];
if (order && fulfillment.status?.code !== 200) {
order.status = fulfillment.status;
Expand All @@ -1608,7 +1606,7 @@ export class OrderingService
throw error;
}
).finally(
() => response.fulfillments.push(...Object.values(fulfillment_map))
() => response.fulfillments = Object.values(fulfillment_map)
);
}

Expand Down

0 comments on commit 30535e1

Please sign in to comment.