Skip to content

Commit

Permalink
fix: ensure Invite to Pay creates submission events for S3/Power Auto…
Browse files Browse the repository at this point in the history
…mate (#4068)
  • Loading branch information
jessicamcinchak authored Dec 11, 2024
1 parent 79b90d9 commit d7e3c5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const createPaymentSendEvents = async (
}

// Find this sessions Send component, determine which "destinations" we need to queue up events for
// REMINDER to keep these destinations in sync with api.planx.uk/modules/send/createSendEvents/controller.ts
const sendNode: [string, Node] | undefined = Object.entries(
publishedFlowData,
).find(([_nodeId, nodeData]) => nodeData.type === ComponentType.Send);
Expand All @@ -54,7 +55,7 @@ const createPaymentSendEvents = async (
if (destinations.includes("bops")) {
const bopsEvent = await createScheduledEvent({
webhook: `{{HASURA_PLANX_API_URL}}/bops/${teamSlug}`,
schedule_at: now,
schedule_at: new Date(now.getTime() + 15 * 1000),
payload: eventPayload,
comment: `bops_submission_${payload.sessionId}`,
});
Expand Down Expand Up @@ -91,13 +92,23 @@ const createPaymentSendEvents = async (

const uniformEvent = await createScheduledEvent({
webhook: `{{HASURA_PLANX_API_URL}}/uniform/${teamSlug}`,
schedule_at: now,
schedule_at: new Date(now.getTime() + 30 * 1000),
payload: eventPayload,
comment: `uniform_submission_${payload.sessionId}`,
});
combinedResponse["uniform"] = uniformEvent;
}

if (destinations.includes("s3")) {
const s3Event = await createScheduledEvent({
webhook: `{{HASURA_PLANX_API_URL}}/upload-submission/${teamSlug}`,
schedule_at: now,
payload: eventPayload,
comment: `upload_submission_${payload.sessionId}`,
});
combinedResponse["s3"] = s3Event;
}

return res.json(combinedResponse);
} catch (error) {
return next({
Expand Down
1 change: 1 addition & 0 deletions api.planx.uk/modules/send/createSendEvents/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createScheduledEvent } from "../../../lib/hasura/metadata/index.js";
import type { CreateSendEventsController } from "./types.js";

// Create "One-off Scheduled Events" in Hasura from Send component for selected destinations
// REMINDER to keep these destinations in sync with api.planx.uk/modules/pay/service/inviteToPay/createPaymentSendEvents.ts
const createSendEvents: CreateSendEventsController = async (
_req,
res,
Expand Down

0 comments on commit d7e3c5a

Please sign in to comment.