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: ensure Invite to Pay creates submission events for S3/Power Automate #4068

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
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
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
Loading