Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RFC-6638 Schedule Agent Parameter #248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,22 +213,22 @@ async function handleDownload() {
if (error) {
reject(error)
}

resolve(new File([value], filename, { type: 'text/calendar' }))
})
})
const url = URL.createObjectURL(file);

// trying to assign the file URL to a window could cause cross-site
// issues so this is a workaround using HTML5
const anchor = document.createElement('a');
anchor.href = url;
anchor.download = filename;

document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);

URL.revokeObjectURL(url);
}
```
Expand Down Expand Up @@ -263,8 +263,8 @@ The following properties are accepted:
| geo | Geographic coordinates (lat/lon) | `{ lat: 38.9072, lon: 77.0369 }`
| url | URL associated with event | `'http://www.mountainsunpub.com/'`
| status | Three statuses are allowed: `TENTATIVE`, `CONFIRMED`, `CANCELLED` | `CONFIRMED`
| organizer | Person organizing the event | `{ name: 'Adam Gibbons', email: '[email protected]', dir: 'https://linkedin.com/in/adamgibbons', sentBy: '[email protected]' }`
| attendees | Persons invited to the event | `[{ name: 'Mo', email: '[email protected]', rsvp: true }, { name: 'Bo', email: '[email protected]', dir: 'https://twitter.com/bo1234', partstat: 'ACCEPTED', role: 'REQ-PARTICIPANT' }]`
| organizer | Person organizing the event | `{ name: 'Adam Gibbons', email: '[email protected]', dir: 'https://linkedin.com/in/adamgibbons', sentBy: '[email protected]', scheduleAgent: 'SERVER' }`
| attendees | Persons invited to the event | `[{ name: 'Mo', email: '[email protected]', rsvp: true }, { name: 'Bo', email: '[email protected]', dir: 'https://twitter.com/bo1234', partstat: 'ACCEPTED', role: 'REQ-PARTICIPANT', scheduleAgent: 'CLIENT' }]`
| categories | Categories associated with the event | `['hacknight', 'stout month']`
| alarms | Alerts that can be set to trigger before, during, or after the event. The following `attach` properties work on Mac OS: Basso, Blow, Bottle, Frog, Funk, Glass, Hero, Morse, Ping, Pop, Purr, Sousumi, Submarine, Tink | `{ action: 'display', description: 'Reminder', trigger: [2000, 1, 4, 18, 30] }` OR `{ action: 'display', description: 'Reminder', trigger: { hours: 2, minutes: 30, before: true } }` OR `{ action: 'display', description: 'Reminder', trigger: { hours: 2, minutes: 30, before: false }` OR `{ action: 'audio', description: 'Reminder', trigger: { hours: 2, minutes: 30, before: true }, repeat: 2, attachType: 'VALUE=URI', attach: 'Glass' }`
| productId | Product which created ics, `PRODID` field | `'adamgibbons/ics'`
Expand Down
8 changes: 5 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type Attendee = Person & {
rsvp?: boolean;
partstat?: ParticipationStatus;
role?: ParticipationRole;
scheduleAgent?: 'SERVER' | 'CLIENT' | 'NONE';
};

export type ActionType = 'audio' | 'display' | 'email' | 'procedure';
Expand Down Expand Up @@ -81,15 +82,16 @@ export type EventAttributes = {
url?: string;
status?: EventStatus;
busyStatus?: 'FREE' | 'BUSY' | 'TENTATIVE' | 'OOF';

organizer?: Person & {
sentBy?: string;
scheduleAgent?: 'SERVER' | 'CLIENT' | 'NONE';
};
attendees?: Attendee[];

categories?: string[];
alarms?: Alarm[];

productId?: string;
uid?: string;
method?: string;
Expand Down
6 changes: 4 additions & 2 deletions src/schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ const contactSchema = yup.object().shape({
rsvp: yup.boolean(),
dir: yup.string().matches(urlRegex),
partstat: yup.string(),
role: yup.string()
role: yup.string(),
scheduleAgent: yup.string()
}).noUnknown()

const organizerSchema = yup.object().shape({
name: yup.string(),
email: yup.string().email(),
dir: yup.string(),
sentBy: yup.string()
sentBy: yup.string(),
scheduleAgent: yup.string()
}).noUnknown()

const alarmSchema = yup.object().shape({
Expand Down
3 changes: 2 additions & 1 deletion src/utils/set-contact.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export default function setContact({ name, email, rsvp, dir, partstat, role }) {
export default function setContact({ name, email, rsvp, dir, partstat, role, scheduleAgent }) {
let formattedAttendee = ''
formattedAttendee += rsvp ? 'RSVP=TRUE;' : 'RSVP=FALSE;'
formattedAttendee += role ? `ROLE=${role};` : ''
formattedAttendee += partstat ? `PARTSTAT=${partstat};` : ''
formattedAttendee += dir ? `DIR=${dir};` : ''
formattedAttendee += scheduleAgent ? `SCHEDULE-AGENT=${scheduleAgent};` : ''
formattedAttendee += 'CN='
formattedAttendee += name || 'Unnamed attendee'
formattedAttendee += email ? `:mailto:${email}` : ''
Expand Down
3 changes: 2 additions & 1 deletion src/utils/set-organizer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export default function setOrganizer({ name, email, dir, sentBy }) {
export default function setOrganizer({ name, email, dir, sentBy, scheduleAgent }) {
let formattedOrganizer = ''
formattedOrganizer += dir ? `DIR="${dir}";` : ''
formattedOrganizer += sentBy ? `SENT-BY="MAILTO:${sentBy}";` : ''
formattedOrganizer += scheduleAgent ? `SCHEDULE-AGENT=${scheduleAgent};` : ''
formattedOrganizer += 'CN='
formattedOrganizer += name || 'Organizer'
formattedOrganizer += email ? `:MAILTO:${email}` : ''
Expand Down
7 changes: 4 additions & 3 deletions test/pipeline/format.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ describe('pipeline.formatEvent', () => {

it('writes attendees', () => {
const event = buildEvent({ attendees: [
{name: 'Adam Gibbons', email: '[email protected]'},
{name: 'Adam Gibbons', email: '[email protected]', scheduleAgent: 'CLIENT'},
{name: 'Brittany Seaton', email: '[email protected]', rsvp: true }
]})
const formattedEvent = formatEvent(event)
expect(formattedEvent).to.contain('ATTENDEE;RSVP=FALSE;CN=Adam Gibbons:mailto:[email protected]')
expect(formattedEvent).to.contain('ATTENDEE;RSVP=FALSE;SCHEDULE-AGENT=CLIENT;CN=Adam Gibbons:mailto:[email protected]')
expect(formattedEvent).to.contain('ATTENDEE;RSVP=TRUE;CN=Brittany Seaton:mailto:[email protected]')
})
it('writes a busystatus', () => {
Expand Down Expand Up @@ -212,8 +212,9 @@ describe('pipeline.formatEvent', () => {
email: '[email protected]',
dir: 'test-dir-value',
sentBy: '[email protected]'
scheduleAgent: 'SERVER'
}})
expect(formattedEvent).to.contain(foldLine('ORGANIZER;DIR="test-dir-value";SENT-BY="MAILTO:[email protected]";CN=Adam Gibbons:MAILTO:[email protected]'))
expect(formattedEvent).to.contain(foldLine('ORGANIZER;DIR="test-dir-value";SENT-BY="MAILTO:[email protected]";SCHEDULE-AGENT=SERVER;CN=Adam Gibbons:MAILTO:[email protected]'))
})
it('writes an alarm', () => {
const formattedEvent = formatEvent({ alarms: [{
Expand Down