Skip to content

Scheduling infrastructure for absolutely everyone.

updated event title message (#1132)

Syed Ali Shahbaza404ca847c73
diff --git a/lib/event.ts b/lib/event.ts
index 82b969d2157..b261b627a5c 100644
--- a/lib/event.ts
+++ b/lib/event.ts
@@ -1,8 +1,19 @@
-export function getEventName(
- name: string | string[] | undefined,
- eventTitle: string,
- eventNameTemplate: string | null
-) {
- if (!name || !(typeof name === "string")) name = ""; // If name is not set or is not of proper type
- return eventNameTemplate ? eventNameTemplate.replace("{USER}", name) : eventTitle + " with " + name;
+import { TFunction } from "next-i18next";
+
+type EventNameObjectType = {
+ attendeeName: string;
+ eventType: string;
+ eventName?: string | null;
+ host: string;
+ t: TFunction;
+};
+
+export function getEventName(eventNameObj: EventNameObjectType) {
+ return eventNameObj.eventName
+ ? eventNameObj.eventName.replace("{USER}", eventNameObj.attendeeName)
+ : eventNameObj.t("event_between_users", {
+ eventName: eventNameObj.eventType,
+ host: eventNameObj.host,
+ attendeeName: eventNameObj.attendeeName,
+ });
}
diff --git a/pages/api/book/event.ts b/pages/api/book/event.ts
index 893b689daf5..22204345274 100644
--- a/pages/api/book/event.ts
+++ b/pages/api/book/event.ts
@@ -263,9 +263,17 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const seed = `${users[0].username}:${dayjs(req.body.start).utc().format()}:${new Date().getTime()}`;
const uid = translator.fromUUID(uuidv5(seed, uuidv5.URL));
+ const eventNameObject = {
+ attendeeName: reqBody.name || "Nameless",
+ eventType: eventType.title,
+ eventName: eventType.eventName,
+ host: users[0].name || "Nameless",
+ t,
+ };
+
const evt: CalendarEvent = {
type: eventType.title,
- title: getEventName(reqBody.name, eventType.title, eventType.eventName),
+ title: getEventName(eventNameObject),
description: reqBody.notes,
startTime: reqBody.start,
endTime: reqBody.end,
@@ -488,6 +496,7 @@ 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 subscriberUrls = await getSubscriberUrls(user.id, eventTrigger);
+ console.log("evt:", evt);
const promises = subscriberUrls.map((url) =>
sendPayload(eventTrigger, new Date().toISOString(), url, evt).catch((e) => {
console.error(`Error executing webhook for event: ${eventTrigger}, URL: ${url}`, e);
diff --git a/pages/success.tsx b/pages/success.tsx
index 094067f2a3d..b0d6c177357 100644
--- a/pages/success.tsx
+++ b/pages/success.tsx
@@ -39,7 +39,17 @@ export default function Success(props: inferSSRProps<typeof getServerSideProps>)
setIs24h(!!localStorage.getItem("timeOption.is24hClock"));
}, []);
- const eventName = getEventName(name, props.eventType.title, props.eventType.eventName);
+ const attendeeName = typeof name === "string" ? name : "Nameless";
+
+ const eventNameObject = {
+ attendeeName,
+ eventType: props.eventType.title,
+ eventName: props.eventType.eventName,
+ host: props.profile.name || "Nameless",
+ t,
+ };
+
+ const eventName = getEventName(eventNameObject);
function eventLink(): string {
const optional: { location?: string } = {};
diff --git a/playwright/integrations.test.ts b/playwright/integrations.test.ts
index 5405742f778..dbe280c37e0 100644
--- a/playwright/integrations.test.ts
+++ b/playwright/integrations.test.ts
@@ -89,7 +89,7 @@ describe("webhooks", () => {
"timeZone": "[redacted/dynamic]",
},
"startTime": "[redacted/dynamic]",
- "title": "30min with Test Testson",
+ "title": "30min between Pro Example and Test Testson",
"type": "30min",
"uid": "[redacted/dynamic]",
},
diff --git a/public/static/locales/en/common.json b/public/static/locales/en/common.json
index 8f103ccdaa6..fb8f9a0e0d5 100644
--- a/public/static/locales/en/common.json
+++ b/public/static/locales/en/common.json
@@ -222,6 +222,7 @@
"no_meeting_found_description": "This meeting does not exist. Contact the meeting owner for an updated link.",
"no_status_bookings_yet": "No {{status}} bookings, yet",
"no_status_bookings_yet_description": "You have no {{status}} bookings. {{description}}",
+ "event_between_users": "{{eventName}} between {{host}} and {{attendeeName}}",
"bookings": "Bookings",
"bookings_description": "See upcoming and past events booked through your event type links.",
"upcoming_bookings": "As soon as someone books a time with you it will show up here.",