-
Notifications
You must be signed in to change notification settings - Fork 12k
feat: implement unreachable calendar notifications system #23649
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
Draft
Vansh5632
wants to merge
6
commits into
calcom:main
Choose a base branch
from
Vansh5632:feature/unreachable-calendar-notifications
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
66036af
feat: implement unreachable calendar notifications system
Vansh5632 1240e90
feat: integrate calendar notifications into main calendars settings
Vansh5632 d4d3954
Merge branch 'main' into feature/unreachable-calendar-notifications
kart1ka a8835ed
implemented the suggestions of coderabbit
Vansh5632 741e51d
Merge upstream/main into feature/unreachable-calendar-notifications
devin-ai-integration[bot] 66bfc3e
Address CodeRabbit review feedback for unreachable calendar notificat…
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
packages/emails/templates/unreachable-calendar-email.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| import { EMAIL_FROM_NAME, WEBAPP_URL } from "@calcom/lib/constants"; | ||
|
|
||
| import BaseEmail from "./_base-email"; | ||
|
|
||
| export class UnreachableCalendarEmail extends BaseEmail { | ||
| recipientEmail: string; | ||
| recipientName?: string; | ||
| calendarName: string; | ||
| reason: string; | ||
|
|
||
| private esc(str: string): string { | ||
| return str | ||
| .replace(/&/g, "&") | ||
| .replace(/</g, "<") | ||
| .replace(/>/g, ">") | ||
| .replace(/"/g, """) | ||
| .replace(/'/g, "'"); | ||
| } | ||
|
|
||
| constructor({ | ||
| recipientEmail, | ||
| recipientName, | ||
| calendarName, | ||
| reason, | ||
| }: { | ||
| recipientEmail: string; | ||
| recipientName?: string; | ||
| calendarName: string; | ||
| reason: string; | ||
| }) { | ||
| super(); | ||
| this.name = "UNREACHABLE_CALENDAR"; | ||
| this.recipientEmail = recipientEmail; | ||
| this.recipientName = recipientName; | ||
| this.calendarName = calendarName; | ||
| this.reason = reason; | ||
| } | ||
|
|
||
| protected async getNodeMailerPayload(): Promise<Record<string, unknown>> { | ||
| return { | ||
| from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`, | ||
| to: this.recipientEmail, | ||
| subject: `Action needed: Your ${this.calendarName} is unreachable`, | ||
| html: await this.getHtml(), | ||
| text: this.getTextBody(), | ||
| }; | ||
| } | ||
|
|
||
| async getHtml() { | ||
| const escapedCalendarName = this.esc(this.calendarName); | ||
| const escapedRecipientName = this.recipientName ? this.esc(this.recipientName) : undefined; | ||
| const escapedReason = this.reason ? this.esc(this.reason) : undefined; | ||
|
|
||
| return ` | ||
| <div style="font-family: Arial, sans-serif;"> | ||
| <h2>Action Required: Your ${escapedCalendarName} is unreachable</h2> | ||
| <p> | ||
| ${escapedRecipientName ? `Hi ${escapedRecipientName},` : "Hello,"} | ||
| </p> | ||
| <p> | ||
| Your linked calendar <strong>${escapedCalendarName}</strong> is no longer reachable. | ||
| ${escapedReason ? `Reason: ${escapedReason}.` : ""} | ||
| Until you reconnect or remove it, invitees will see no availability on your booking pages. | ||
| </p> | ||
| <p> | ||
| <strong>What this means:</strong> | ||
| </p> | ||
| <ul> | ||
| <li>Your booking links will show no available time slots</li> | ||
| <li>Potential meetings may be missed</li> | ||
| <li>Cal.com cannot check for conflicts or add new events to your calendar</li> | ||
| </ul> | ||
| <p> | ||
| <strong>How to fix this:</strong> | ||
| </p> | ||
| <p> | ||
| Please log in to your Cal.com account and reconnect your calendar from your settings page: | ||
| <br /> | ||
| <a href="${WEBAPP_URL}/settings/my-account/calendars" style="color: #3b82f6; text-decoration: none;"> | ||
| ${WEBAPP_URL}/settings/my-account/calendars | ||
| </a> | ||
| </p> | ||
| <p> | ||
| If you no longer use this calendar, you can safely remove it from your Cal.com settings. | ||
| </p> | ||
| <p> | ||
| If you have already reconnected your calendar, you can ignore this message. | ||
| </p> | ||
| <p> | ||
| Thank you,<br /> | ||
| The Cal.com Team | ||
| </p> | ||
| </div> | ||
| `; | ||
| } | ||
|
|
||
| protected getTextBody(): string { | ||
| return `Action Required: Your ${this.calendarName} is unreachable | ||
|
|
||
| ${this.recipientName ? `Hi ${this.recipientName},` : "Hello,"} | ||
|
|
||
| Your linked calendar ${this.calendarName} is no longer reachable. ${ | ||
| this.reason ? `Reason: ${this.reason}.` : "" | ||
| } Until you reconnect or remove it, invitees will see no availability on your booking pages. | ||
|
|
||
| What this means: | ||
| - Your booking links will show no available time slots | ||
| - Potential meetings may be missed | ||
| - Cal.com cannot check for conflicts or add new events to your calendar | ||
|
|
||
| How to fix this: | ||
| Please log in to your Cal.com account and reconnect your calendar from your settings page: ${WEBAPP_URL}/settings/my-account/calendars | ||
|
|
||
| If you no longer use this calendar, you can safely remove it from your Cal.com settings. | ||
|
|
||
| If you have already reconnected your calendar, you can ignore this message. | ||
|
|
||
| Thank you, | ||
| The Cal.com Team`; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sanitize dynamic values used in the email template (subject/body) to prevent HTML/header injection
calendarName,recipientName, and especiallyreasonmay contain provider/error strings. Ensure they’re HTML-escaped in the template (and header-safe in subject). If not handled in the template, add escaping there.Below change applies to packages/emails/templates/unreachable-calendar-email.ts:
@@ export default class UnreachableCalendarEmail extends BaseEmail { @@ - protected async getNodeMailerPayload(): Promise<Record<string, unknown>> { + private esc(s?: string) { + if (!s) return ""; + return String(s) + .replace(/&/g, "&") + .replace(/</g, "<") + .replace(/>/g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); + } + + protected async getNodeMailerPayload(): Promise<Record<string, unknown>> { return { - from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`, - to: this.recipientEmail, - subject: `Action needed: Your ${this.calendarName} is unreachable`, + from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`, + to: this.recipientEmail, + subject: `Action needed: Your ${this.esc(this.calendarName)} is unreachable`, html: await this.getHtml(), text: this.getTextBody(), }; } async getHtml() { return ` <div style="font-family: Arial, sans-serif;"> - <h2>Action Required: Your ${this.calendarName} is unreachable</h2> + <h2>Action Required: Your ${this.esc(this.calendarName)} is unreachable</h2> <p> - ${this.recipientName ? `Hi ${this.recipientName},` : "Hello,"} + ${this.recipientName ? `Hi ${this.esc(this.recipientName)},` : "Hello,"} </p> <p> - Your linked calendar <strong>${this.calendarName}</strong> is no longer reachable. - ${this.reason ? `Reason: ${this.reason}.` : ""} + Your linked calendar <strong>${this.esc(this.calendarName)}</strong> is no longer reachable. + ${this.reason ? `Reason: ${this.esc(this.reason)}.` : ""} Until you reconnect or remove it, invitees will see no availability on your booking pages. </p> @@ protected getTextBody(): string { - return `Action Required: Your ${this.calendarName} is unreachable + return `Action Required: Your ${this.calendarName} is unreachable -${this.recipientName ? `Hi ${this.recipientName},` : "Hello,"} +${this.recipientName ? `Hi ${this.recipientName},` : "Hello,"} Your linked calendar ${this.calendarName} is no longer reachable. ${ this.reason ? `Reason: ${this.reason}.` : "" } Until you reconnect or remove it, invitees will see no availability on your booking pages.Optionally, also escape values in the text body for consistency, though risk is lower there.
📝 Committable suggestion