Skip to content

Commit

Permalink
Add @channel ping to reminder message for only five-minute reminders
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumManiac committed Jan 10, 2024
1 parent a770d26 commit 8f58292
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/utils/eventReminders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ export function remindUpcomingEvents(events: CalendarEvent[], client: WebClient)
* @returns The generated reminder text
*/
export function generateEventReminderText(event: CalendarEvent, reminderType: EventReminderType): string {
let message = `<!channel>\nReminder: *${event.title}* is occurring`;
let message = `${reminderType == EventReminderType.FIVE_MINUTES ? "<!channel>\n" : ""}Reminder: *${
event.title
}* is occurring`;

if (reminderType === EventReminderType.FIVE_MINUTES) {
const timeUntilEvent = event.start.getTime() - new Date().getTime();
Expand Down
12 changes: 8 additions & 4 deletions tests/unit/utils/meetingReminders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ Ways to attend:
const result = generateEventReminderText(event, EventReminderType.FIVE_MINUTES);

expect(result).toBe(
`Reminder: *Test event* is occurring in *5 minutes*
`<!channel>
Reminder: *Test event* is occurring in *5 minutes*
<https://www.google.com/calendar/event?eid=MGJyczFiMjJuZHJjZzRnZmx0Z2c1OGRocmkgdXdhdGVybG9vLnJvY2tldHJ5LmRxxxxx|Event Details>
Ways to attend:
\t:office: In person @ Test location
Expand Down Expand Up @@ -199,7 +200,8 @@ Ways to attend:
const result = generateEventReminderText(event, EventReminderType.FIVE_MINUTES);

expect(result).toBe(
`Reminder: *Test event* is occurring in *5 minutes*
`<!channel>
Reminder: *Test event* is occurring in *5 minutes*
<https://www.google.com/calendar/event?eid=MGJyczFiMjJuZHJjZzRnZmx0Z2c1OGRocmkgdXdhdGVybG9vLnJvY2tldHJ5LmRxxxxx|Event Details>
Ways to attend:
\t:globe_with_meridians: Online @ https://meet.waterloorocketry.com/bay_area`,
Expand Down Expand Up @@ -232,7 +234,8 @@ Ways to attend:
const result = generateEventReminderText(event, EventReminderType.FIVE_MINUTES);

expect(result).toBe(
`Reminder: *Test event* is occurring in *5 minutes*
`<!channel>
Reminder: *Test event* is occurring in *5 minutes*
<https://www.google.com/calendar/event?eid=MGJyczFiMjJuZHJjZzRnZmx0Z2c1OGRocmkgdXdhdGVybG9vLnJvY2tldHJ5LmRxxxxx|Event Details>
Ways to attend:
\t:office: In person @ Test location
Expand Down Expand Up @@ -265,7 +268,8 @@ Ways to attend:
const result = generateEventReminderText(event, EventReminderType.FIVE_MINUTES);

expect(result).toBe(
`Reminder: *Test event* is occurring in *5 minutes*
`<!channel>
Reminder: *Test event* is occurring in *5 minutes*
<https://www.google.com/calendar/event?eid=MGJyczFiMjJuZHJjZzRnZmx0Z2c1OGRocmkgdXdhdGVybG9vLnJvY2tldHJ5LmRxxxxx|Event Details>
Ways to attend:
\t:globe_with_meridians: Online @ https://example.com`,
Expand Down

0 comments on commit 8f58292

Please sign in to comment.