diff --git a/apps/web/pages/api/book/event.ts b/apps/web/pages/api/book/event.ts index 5eb9d167..d9e2f7dd 100644 --- a/apps/web/pages/api/book/event.ts +++ b/apps/web/pages/api/book/event.ts @@ -232,6 +232,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) currency: true, metadata: true, destinationCalendar: true, + hideCalendarNotes: true, }, }); @@ -342,6 +343,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) location: reqBody.location, // Will be processed by the EventManager later. /** For team events, we will need to handle each member destinationCalendar eventually */ destinationCalendar: eventType.destinationCalendar || users[0].destinationCalendar, + hideCalendarNotes: eventType.hideCalendarNotes, }; if (eventType.schedulingType === SchedulingType.COLLECTIVE) { diff --git a/apps/web/playwright/integrations.test.ts-snapshots/webhookResponse-chromium.txt b/apps/web/playwright/integrations.test.ts-snapshots/webhookResponse-chromium.txt index c67a1932..51471113 100644 --- a/apps/web/playwright/integrations.test.ts-snapshots/webhookResponse-chromium.txt +++ b/apps/web/playwright/integrations.test.ts-snapshots/webhookResponse-chromium.txt @@ -1 +1 @@ -{"triggerEvent":"BOOKING_CREATED","createdAt":"[redacted/dynamic]","payload":{"type":"30min","title":"30min between Pro Example and Test Testson","description":"","startTime":"[redacted/dynamic]","endTime":"[redacted/dynamic]","organizer":{"name":"Pro Example","email":"pro@example.com","timeZone":"[redacted/dynamic]","language":"[redacted/dynamic]"},"attendees":[{"email":"test@example.com","name":"Test Testson","timeZone":"[redacted/dynamic]","language":"[redacted/dynamic]"}],"location":"[redacted/dynamic]","destinationCalendar":null,"uid":"[redacted/dynamic]","metadata":{},"additionInformation":"[redacted/dynamic]"}} \ No newline at end of file +{"triggerEvent":"BOOKING_CREATED","createdAt":"[redacted/dynamic]","payload":{"type":"30min","title":"30min between Pro Example and Test Testson","description":"","startTime":"[redacted/dynamic]","endTime":"[redacted/dynamic]","organizer":{"name":"Pro Example","email":"pro@example.com","timeZone":"[redacted/dynamic]","language":"[redacted/dynamic]"},"attendees":[{"email":"test@example.com","name":"Test Testson","timeZone":"[redacted/dynamic]","language":"[redacted/dynamic]"}],"location":"[redacted/dynamic]","destinationCalendar":null,"hideCalendarNotes":false,"uid":"[redacted/dynamic]","metadata":{},"additionInformation":"[redacted/dynamic]"}} \ No newline at end of file diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index 7ade26b4..bc212f9d 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -566,6 +566,8 @@ "type": "Type", "edit": "Edit", "add_input": "Add an Input", + "disable_notes": "Hide notes in calendar", + "disable_notes_description": "For privacy reasons, additional inputs and notes will be hidden in the calendar entry. They will still be sent to your email.", "opt_in_booking": "Opt-in Booking", "opt_in_booking_description": "The booking needs to be manually confirmed before it is pushed to the integrations and a confirmation mail is sent.", "disable_guests": "Disable Guests", diff --git a/packages/core/CalendarManager.ts b/packages/core/CalendarManager.ts index 961a4dfd..8b6f544c 100644 --- a/packages/core/CalendarManager.ts +++ b/packages/core/CalendarManager.ts @@ -102,12 +102,17 @@ export const createEvent = async (credential: Credential, calEvent: CalendarEven const calendar = getCalendar(credential); let success = true; + // Check if the disabledNotes flag is set to true + if (calEvent.hideCalendarNotes) { + calEvent.description = "Notes have been hidden by the organiser"; // TODO: i18n this string? + } + const creationResult = calendar ? await calendar.createEvent(calEvent).catch((e) => { - log.error("createEvent failed", e, calEvent); - success = false; - return undefined; - }) + log.error("createEvent failed", e, calEvent); + success = false; + return undefined; + }) : undefined; return { @@ -131,10 +136,10 @@ export const updateEvent = async ( const updatedResult = calendar && bookingRefUid ? await calendar.updateEvent(bookingRefUid, calEvent).catch((e) => { - log.error("updateEvent failed", e, calEvent); - success = false; - return undefined; - }) + log.error("updateEvent failed", e, calEvent); + success = false; + return undefined; + }) : undefined; return { diff --git a/packages/prisma/migrations/20220323162642_events_hide_notes/migration.sql b/packages/prisma/migrations/20220323162642_events_hide_notes/migration.sql new file mode 100644 index 00000000..b0dc4004 --- /dev/null +++ b/packages/prisma/migrations/20220323162642_events_hide_notes/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "EventType" ADD COLUMN "hideCalendarNotes" BOOLEAN NOT NULL DEFAULT false; diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prisma index 0d8e6087..6bcf9e30 100644 --- a/packages/prisma/schema.prisma +++ b/packages/prisma/schema.prisma @@ -58,6 +58,7 @@ model EventType { periodCountCalendarDays Boolean? requiresConfirmation Boolean @default(false) disableGuests Boolean @default(false) + hideCalendarNotes Boolean @default(false) minimumBookingNotice Int @default(120) beforeEventBuffer Int @default(0) afterEventBuffer Int @default(0) diff --git a/packages/types/Calendar.d.ts b/packages/types/Calendar.d.ts index 57cd9ea2..0708eb3f 100644 --- a/packages/types/Calendar.d.ts +++ b/packages/types/Calendar.d.ts @@ -91,6 +91,7 @@ export interface CalendarEvent { destinationCalendar?: DestinationCalendar | null; cancellationReason?: string | null; rejectionReason?: string | null; + hideCalendarNotes?: boolean; } export interface EntryPoint {