Feature/field prefills (#1249)
* Needs more testing, but looks functional * Add metadata feature to booking create payload * Forward URL parameters given in link * Moved stringifying of custom inputs to backend
This commit is contained in:
1 parent
8d1d3fcc7a
commit
8c1b69cc0f
5 files changed
+310
-237
No files matched your search
+24
-8
@@ -238,7 +238,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
}
|
||||
|
||||
const invitee = [{ email: reqBody.email, name: reqBody.name, timeZone: reqBody.timeZone }];
|
||||
const guests = reqBody.guests.map((guest) => {
|
||||
const guests = (reqBody.guests || []).map((guest) => {
|
||||
const g = {
|
||||
email: guest,
|
||||
name: "",
|
||||
@@ -269,10 +269,16 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
t,
|
||||
};
|
||||
|
||||
const description =
|
||||
reqBody.customInputs.reduce((str, input) => str + input.label + "\n" + input.value + "\n\n", "") +
|
||||
t("additional_notes") +
|
||||
":\n" +
|
||||
reqBody.notes;
|
||||
|
||||
const evt: CalendarEvent = {
|
||||
type: eventType.title,
|
||||
title: getEventName(eventNameObject),
|
||||
description: reqBody.notes,
|
||||
description,
|
||||
startTime: reqBody.start,
|
||||
endTime: reqBody.end,
|
||||
organizer: {
|
||||
@@ -513,13 +519,23 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
const eventTrigger = rescheduleUid ? "BOOKING_RESCHEDULED" : "BOOKING_CREATED";
|
||||
// Send Webhook call if hooked to BOOKING_CREATED & BOOKING_RESCHEDULED
|
||||
const subscribers = await getSubscribers(user.id, eventTrigger);
|
||||
console.log("evt:", evt);
|
||||
console.log("evt:", {
|
||||
...evt,
|
||||
metadata: reqBody.metadata,
|
||||
});
|
||||
const promises = subscribers.map((sub) =>
|
||||
sendPayload(eventTrigger, new Date().toISOString(), sub.subscriberUrl, evt, sub.payloadTemplate).catch(
|
||||
(e) => {
|
||||
console.error(`Error executing webhook for event: ${eventTrigger}, URL: ${sub.subscriberUrl}`, e);
|
||||
}
|
||||
)
|
||||
sendPayload(
|
||||
eventTrigger,
|
||||
new Date().toISOString(),
|
||||
sub.subscriberUrl,
|
||||
{
|
||||
...evt,
|
||||
metadata: reqBody.metadata,
|
||||
},
|
||||
sub.payloadTemplate
|
||||
).catch((e) => {
|
||||
console.error(`Error executing webhook for event: ${eventTrigger}, URL: ${sub.subscriberUrl}`, e);
|
||||
})
|
||||
);
|
||||
await Promise.all(promises);
|
||||
|
||||
|
||||
Reference in new issue
Block a user