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

chore: Fixing ICS file in workflows & ICS calendar descriptions [CAL-4409] #16731

Merged
merged 20 commits into from
Oct 7, 2024

Conversation

joeauyeung
Copy link
Contributor

@joeauyeung joeauyeung commented Sep 19, 2024

What does this PR do?

For our emails we use generateIcsString() while in workflows they had their own function to generate ICS strings. We should keep the calendar events unified. By doing this we solve two problems

  • Double calendar events on calendars because the ICS file had a different UID than the calendar event we created when the booking was made
  • Syncing calendar events with relevant information by removing the title and subtitle from the calendar description

Before

CleanShot 2024-09-19 at 15 10 13@2x

After

CleanShot 2024-09-19 at 15 10 31@2x

  • Fixes #XXXX (GitHub issue number)
  • Fixes CAL-4409 (Linear issue number - should be visible at the bottom of the GitHub issue description)

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have added a Docs issue here if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings

@keithwillcode keithwillcode added consumer core area: core, team members only labels Sep 19, 2024
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the title, subtitle, role, and isRequestRescheduled params as they are not needed anymore.

@@ -283,7 +282,9 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
attachments: reminder.workflowStep.includeCalendarEvent
? [
{
content: Buffer.from(getiCalEventAsString(reminder.booking) || "").toString("base64"),
content: Buffer.from(
generateIcsString({ event: reminder.booking, status: "CONFIRMED" }) || ""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assume that we only schedule workflow emails for confirmed bookings.

@@ -258,12 +207,8 @@ export const scheduleEmailReminder = async (args: scheduleEmailReminderArgs) =>
const batchId = await getBatchId();

function sendEmail(data: Partial<MailData>, triggerEvent?: WorkflowTriggerEvents) {
const status: ParticipationStatus =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This status should be for the whole event and not just an attendee.

@@ -258,12 +207,8 @@ export const scheduleEmailReminder = async (args: scheduleEmailReminderArgs) =>
const batchId = await getBatchId();

function sendEmail(data: Partial<MailData>, triggerEvent?: WorkflowTriggerEvents) {
const status: ParticipationStatus =
triggerEvent === WorkflowTriggerEvents.AFTER_EVENT
? "COMPLETED"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COMPLETED is not part of the ICS standard. Most calendars handle bookings in the past on their own

@joeauyeung joeauyeung marked this pull request as ready for review September 19, 2024 19:17
@graphite-app graphite-app bot requested a review from a team September 19, 2024 19:18
Copy link

vercel bot commented Sep 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Oct 7, 2024 2:19pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Oct 7, 2024 2:19pm

@dosubot dosubot bot added emails area: emails, cancellation email, reschedule email, inbox, spam folder, not getting email workflows area: workflows, automations labels Sep 19, 2024
Copy link

graphite-app bot commented Sep 19, 2024

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (09/19/24)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add foundation team as reviewer" took an action on this PR • (09/25/24)

1 reviewer was added to this PR based on Keith Williams's automation.

Copy link

linear bot commented Sep 25, 2024

@joeauyeung joeauyeung changed the title chore: Fixing ICS file in workflows & ICS calendar descriptions chore: Fixing ICS file in workflows & ICS calendar descriptions [CAL-4409] Sep 25, 2024
Copy link
Member

@CarinaWolli CarinaWolli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you fix the type errors? 🙏

Comment on lines 663 to 685
const organizerT = await getTranslation(bookingInfo.organizer.language.locale, "common");

const attendeePromises = [];
for (const attendee of bookingInfo.attendees) {
attendeePromises.push(
getTranslation(attendee.language.locale ?? "en", "common").then((tAttendee) => ({
...attendee,
language: { translate: tAttendee, locale: attendee.language.locale ?? "en" },
}))
);
}

const attendees = await Promise.all(attendeePromises);

const emailEvent = {
...bookingInfo,
type: bookingInfo.eventType.slug!,
organizer: {
...bookingInfo.organizer,
language: { ...bookingInfo.organizer.language, translate: organizerT },
},
attendees,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to do that in other places too where we call scheduleEmailReminder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on this. I added this logic inside of scheduleEmailReminder so when calling it we don't have to worry about getting all the translations before passing the event object.

Copy link
Contributor

github-actions bot commented Oct 3, 2024

E2E results are ready!

Copy link
Member

@CarinaWolli CarinaWolli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@CarinaWolli CarinaWolli merged commit 0d75703 into main Oct 7, 2024
39 checks passed
@CarinaWolli CarinaWolli deleted the clean-up-ics-generation branch October 7, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working consumer core area: core, team members only emails area: emails, cancellation email, reschedule email, inbox, spam folder, not getting email ready-for-e2e workflows area: workflows, automations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants