Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ export type Person = {
dir?: string;
};

export type ScheduleAgent = 'SERVER' | 'CLIENT' | 'NONE' | string;

export type Attendee = Person & {
rsvp?: boolean;
partstat?: ParticipationStatus;
role?: ParticipationRole;
cutype?: ParticipationType;
xNumGuests?: number;
scheduleAgent?: ScheduleAgent;
};

export type ActionType = 'audio' | 'display' | 'email' | 'procedure';
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ics",
"version": "3.8.1",
"version": "3.9.0",
"description": "iCal (ics) file generator",
"exports": {
"types": "./index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const contactSchema = yup.object().shape({
dir: yup.string().matches(urlRegex),
partstat: yup.string(),
role: yup.string(),
scheduleAgent: yup.string().matches(/^(SERVER|CLIENT|NONE)$/),
cutype: yup.string(),
xNumGuests: yup.number()
}).noUnknown()
Expand Down
5 changes: 4 additions & 1 deletion src/utils/set-contact.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import encodeParamValue from "./encode-param-value";

export default function setContact({ name, email, rsvp, dir, partstat, role, cutype, xNumGuests }) {
export default function setContact({ name, email, rsvp, dir, partstat, role, cutype, xNumGuests, scheduleAgent }) {
let formattedParts = [];

if(rsvp !== undefined){
Expand All @@ -21,6 +21,9 @@ export default function setContact({ name, email, rsvp, dir, partstat, role, cut
if(dir){
formattedParts.push("DIR=".concat(encodeParamValue(dir)));
}
if(scheduleAgent){
formattedParts.push("SCHEDULE-AGENT=".concat(encodeParamValue(scheduleAgent)));
}
formattedParts.push('CN='.concat((encodeParamValue(name || 'Unnamed attendee'))));

var formattedAttendee = formattedParts.join(';').concat(email ? ":mailto:".concat(email) : '');
Expand Down
23 changes: 23 additions & 0 deletions test/utils/set-contact.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,27 @@ describe('utils.setContact', () => {
expect(contactString).to.contain('CUTYPE="INDIVIDUAL"')
expect(contactString).to.contain('X-NUM-GUESTS=0')
})
it('set a contact with schedule-agent', () => {
const contact = { name: 'm-vinc', email: 'vinc@example.com' }
const contactUndefined = Object.assign({scheduleAgent: undefined}, contact)
const contactServer = Object.assign({scheduleAgent: 'SERVER'}, contact)
const contactClient = Object.assign({scheduleAgent: 'CLIENT'}, contact)
const contactNone = Object.assign({scheduleAgent: 'NONE'}, contact)
const contactXCustom = Object.assign({scheduleAgent: 'X-CUSTOM'}, contact)

expect(setContact(contactUndefined))
.to.equal('CN="m-vinc":mailto:vinc@example.com')

expect(setContact(contactServer))
.to.equal('SCHEDULE-AGENT="SERVER";CN="m-vinc":mailto:vinc@example.com')

expect(setContact(contactClient))
.to.equal('SCHEDULE-AGENT="CLIENT";CN="m-vinc":mailto:vinc@example.com')

expect(setContact(contactNone))
.to.equal('SCHEDULE-AGENT="NONE";CN="m-vinc":mailto:vinc@example.com')

expect(setContact(contactXCustom))
.to.equal('SCHEDULE-AGENT="X-CUSTOM";CN="m-vinc":mailto:vinc@example.com')
})
})