1 import { ICAL_ATTENDEE_RSVP } from '@proton/shared/lib/calendar/constants';
2 import { extractEmailAddress } from '@proton/shared/lib/calendar/vcalConverter';
3 import { getAttendeePartstat, getAttendeeRole } from '@proton/shared/lib/calendar/vcalHelper';
4 import { captureMessage } from '@proton/shared/lib/helpers/sentry';
5 import type { AttendeeModel } from '@proton/shared/lib/interfaces/calendar';
6 import type { VcalAttendeeProperty } from '@proton/shared/lib/interfaces/calendar/VcalModel';
8 export const propertiesToAttendeeModel = (attendee?: VcalAttendeeProperty[]): AttendeeModel[] => {
13 .map<AttendeeModel | null>((attendee) => {
14 const email = extractEmailAddress(attendee);
15 if (email === undefined) {
16 captureMessage('Malformed attendee', { extra: { attendee } });
19 const result: AttendeeModel = {
21 rsvp: ICAL_ATTENDEE_RSVP.TRUE,
22 cn: attendee.parameters?.cn || email,
23 partstat: getAttendeePartstat(attendee),
24 role: getAttendeeRole(attendee),
25 token: attendee?.parameters?.['x-pm-token'],
29 .filter<AttendeeModel>((attendee) => attendee !== null);