1 import { getVideoConferencingData } from '@proton/calendar';
2 import { removeZoomInfoFromDescription } from '@proton/calendar/components/videoConferencing/zoom/zoomHelpers';
3 import { EVENT_VERIFICATION_STATUS, MAX_CHARS_API } from '@proton/shared/lib/calendar/constants';
4 import { getDtendProperty } from '@proton/shared/lib/calendar/vcalConverter';
5 import { getVeventStatus } from '@proton/shared/lib/calendar/vcalHelper';
6 import type { EventModelView, SelfAddressData, VcalVeventComponent } from '@proton/shared/lib/interfaces/calendar';
7 import truncate from '@proton/utils/truncate';
9 import { propertiesToAttendeeModel } from './propertiesToAttendeeModel';
10 import propertiesToDateTimeModel from './propertiesToDateTimeModel';
11 import { propertiesToFrequencyModel } from './propertiesToFrequencyModel';
12 import { propertiesToOrganizerModel } from './propertiesToOrganizerModel';
14 const DEFAULT_TIME = {
15 value: { year: 1970, month: 1, day: 1, hours: 0, minutes: 0, seconds: 0, isUTC: true },
16 parameters: { tzid: 'UTC' },
19 export const propertiesToModel = ({
21 hasDefaultNotifications,
22 verificationStatus = EVENT_VERIFICATION_STATUS.NOT_VERIFIED,
28 veventComponent: VcalVeventComponent;
29 hasDefaultNotifications: boolean;
30 verificationStatus?: EVENT_VERIFICATION_STATUS;
31 selfAddressData?: SelfAddressData;
33 isProtonProtonInvite: boolean;
35 }): EventModelView => {
41 dtstart = DEFAULT_TIME,
49 const { start, end } = propertiesToDateTimeModel(dtstart, getDtendProperty(veventComponent), isAllDay, tzid);
50 const { selfAttendeeIndex, selfAddress } = selfAddressData || {};
51 const { meetingId, meetingUrl, password, meetingHost } = getVideoConferencingData(veventComponent);
53 const cleanDescription = removeZoomInfoFromDescription(description?.value ?? '');
56 uid: uid ? uid.value : undefined,
57 frequencyModel: propertiesToFrequencyModel(rrule, start),
58 title: truncate((summary?.value ?? '').trim(), MAX_CHARS_API.TITLE),
59 location: truncate((location?.value ?? '').trim(), MAX_CHARS_API.LOCATION),
60 description: truncate(cleanDescription.trim(), MAX_CHARS_API.EVENT_DESCRIPTION),
62 attendees: propertiesToAttendeeModel(attendee),
63 organizer: propertiesToOrganizerModel(organizer),
65 status: getVeventStatus(veventComponent),
67 isOrganizer: !!selfAddressData?.isOrganizer,
68 isAttendee: !!selfAddressData?.isAttendee,
69 hasDefaultNotifications,
74 conferenceId: meetingId,
75 conferenceUrl: meetingUrl,
76 conferencePassword: password,
77 conferenceHost: meetingHost,