-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(attendee): expose member parameter
Idea and original code by Jonas Heinrich (@onny). Signed-off-by: Richard Steinmetz <[email protected]>
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* @copyright Copyright (c) 2019 Georg Ehrke | ||
* | ||
* @author Georg Ehrke <[email protected]> | ||
* @author Richard Steinmetz <[email protected]> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
|
@@ -207,6 +208,25 @@ export default class AttendeeProperty extends Property { | |
this.value = startStringWith(email, 'mailto:') | ||
} | ||
|
||
/** | ||
* Gets the email addresses of groups the attendee is a part of | ||
* | ||
* @return {string[]|null} The email addresses of the groups | ||
*/ | ||
get member() { | ||
return this.getParameter('MEMBER')?.value ?? null | ||
} | ||
|
||
/** | ||
* Sets the email addresses of groups the attendee is a part of | ||
* | ||
* @param {string[]} members The email addresses of the groups | ||
*/ | ||
set member(members) { | ||
members = members.map(member => startStringWith(member, 'mailto:')) | ||
this.updateParameterIfExist('MEMBER', members) | ||
} | ||
|
||
/** | ||
* Is this attendee the organizer? | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* @copyright Copyright (c) 2019 Georg Ehrke | ||
* | ||
* @author Georg Ehrke <[email protected]> | ||
* @author Richard Steinmetz <[email protected]> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
|
@@ -265,6 +266,36 @@ it('AttendeeProperty should provide easy getter/setter for email', () => { | |
expect(property.email).toEqual('mailto:[email protected]') | ||
}) | ||
|
||
it('AttendeeProperty should provide easy getter/setter for member', () => { | ||
const icalValue = ICAL.Property.fromString('ATTENDEE;MEMBER="mailto:[email protected]","mailto:[email protected]";CN=janedoe:mailto:[email protected]') | ||
const property = AttendeeProperty.fromICALJs(icalValue) | ||
|
||
expect(property.member).toEqual(['mailto:[email protected]', 'mailto:[email protected]']) | ||
|
||
property.member = ['[email protected]'] | ||
expect(property.member).toEqual(['mailto:[email protected]']) | ||
|
||
property.lock() | ||
expect(property.isLocked()).toEqual(true) | ||
|
||
expect(() => { | ||
property.member = ['mailto:[email protected]'] | ||
}).toThrow(ModificationNotAllowedError) | ||
expect(property.member).toEqual(['mailto:[email protected]']) | ||
|
||
property.unlock() | ||
|
||
property.member = ['[email protected]', 'mailto:[email protected]'] | ||
expect(property.member).toEqual(['mailto:[email protected]', 'mailto:[email protected]']) | ||
}) | ||
|
||
it('AttendeeProperty should handle missing member gracefully', () => { | ||
const icalValue = ICAL.Property.fromString('ATTENDEE;CN=Foo;PARTSTAT=DECLINED123;LANGUAGE=EN:mailto:[email protected]') | ||
const property = AttendeeProperty.fromICALJs(icalValue) | ||
|
||
expect(property.member).toEqual(null) | ||
}) | ||
|
||
it('AttendeeProperty should provide easy getter/setter for commonName', () => { | ||
const icalValue = ICAL.Property.fromString('ATTENDEE;CN=Foo;PARTSTAT=DECLINED123;LANGUAGE=EN:mailto:[email protected]') | ||
const property = AttendeeProperty.fromICALJs(icalValue) | ||
|