1 import { buildMailTo } from '../helpers/email';
2 import type { VcalValarmComponent } from '../interfaces/calendar';
3 import { ICAL_ALARM_ACTION } from './constants';
4 import { getSupportedAlarmAction } from './icsSurgery/valarm';
7 * Helper that takes a vAlarm as it's persisted in our database and returns one that is RFC-compatible for PUBLISH method
9 * A description field, as well as summary and attendee fields for email alarms, are mandatory on RFC-5545 (https://datatracker.ietf.org/doc/html/rfc5545#section-3.6.6).
10 * Although we don't store them internally, we need to add them when exporting to other providers. According to the RFC:
12 export const withMandatoryPublishFields = (
13 valarm: VcalValarmComponent,
16 ): VcalValarmComponent => {
17 if (getSupportedAlarmAction(valarm.action).value === ICAL_ALARM_ACTION.EMAIL) {
19 summary: { value: eventTitle }, // <<contains the text to be used as the message subject>>
20 description: { value: eventTitle }, // <<contains the text to be used as the message body>>
21 attendee: [{ value: buildMailTo(calendarEmail) }], // <<contain the email address of attendees to receive the message>>
27 description: { value: eventTitle }, // <<contains the text to be displayed when the alarm is triggered>>