@@ -141,17 +141,20 @@ const DECLINED = 'DECLINED'
141141 * Search a vEvent for an attendee by mail.
142142 *
143143 * @param {EventComponent|undefined|null} vEvent The event providing the attendee haystack.
144- * @param {string} email The email address (with or without a mailto prefix) to use as the needle.
144+ * @param {Array< string>} addresses The email address (with or without a mailto prefix) to use as the needle.
145145 * @return {AttendeeProperty|undefined} The attendee property or undefined if the given email is not matching an attendee.
146146 */
147- function findAttendee (vEvent , email ) {
148- if (! vEvent) {
147+ function findAttendee (vEvent , addresses ) {
148+ if (! vEvent || ! addresses || addresses . length === 0 ) {
149149 return undefined
150150 }
151151
152- email = removeMailtoPrefix (email)
152+ addresses = addresses
153+ .map (addr => addr .toLowerCase ())
154+ .filter (addr => addr .startsWith (' mailto:' ))
155+ .map (removeMailtoPrefix)
153156 for (const attendee of [... vEvent .getPropertyIterator (' ORGANIZER' ), ... vEvent .getAttendeeIterator ()]) {
154- if (removeMailtoPrefix (attendee .email ) === email ) {
157+ if (addresses . includes ( removeMailtoPrefix (attendee .email . toLowerCase ())) ) {
155158 return attendee
156159 }
157160 }
@@ -307,7 +310,10 @@ export default {
307310 * @return {boolean}
308311 */
309312 userIsAttendee () {
310- return !! findAttendee (this .attachedVEvent , this .currentUserPrincipalEmail )
313+ return !! findAttendee (
314+ this .attachedVEvent ,
315+ this .currentUserPrincipal .calendarUserAddressSet ? .length ? this .currentUserPrincipal .calendarUserAddressSet : [this .currentUserPrincipalEmail ],
316+ )
311317 },
312318
313319 /**
@@ -316,7 +322,10 @@ export default {
316322 * @return {string|undefined}
317323 */
318324 existingParticipationStatus () {
319- const attendee = findAttendee (this .existingVEvent , this .currentUserPrincipalEmail )
325+ const attendee = findAttendee (
326+ this .existingVEvent ,
327+ this .currentUserPrincipal .calendarUserAddressSet ? .length ? this .currentUserPrincipal .calendarUserAddressSet : [this .currentUserPrincipalEmail ],
328+ )
320329 return attendee? .participationStatus ?? undefined
321330 },
322331
@@ -430,7 +439,10 @@ export default {
430439 vCalendar = this .attachedVCalendar
431440 }
432441 const vEvent = vCalendar .getFirstComponent (' VEVENT' )
433- const attendee = findAttendee (vEvent, this .currentUserPrincipalEmail )
442+ const attendee = findAttendee (
443+ vEvent,
444+ this .currentUserPrincipal .calendarUserAddressSet ? .length ? this .currentUserPrincipal .calendarUserAddressSet : [this .currentUserPrincipalEmail ],
445+ )
434446 if (! attendee) {
435447 return
436448 }
0 commit comments