Skip to content

Commit

Permalink
Merge branch 'master' into fix/set-date-with-utc-time
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgibbons authored Feb 9, 2019
2 parents c85907f + d519ede commit 43dbc4a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const event = {
status: 'CONFIRMED',
organizer: { name: 'Admin', email: '[email protected]' },
attendees: [
{ name: 'Adam Gibbons', email: '[email protected]', rsvp: true },
{ name: 'Brittany Seaton', email: '[email protected]', dir: 'https://linkedin.com/in/brittanyseaton' }
{ name: 'Adam Gibbons', email: '[email protected]', rsvp: true, partstat: 'ACCEPTED', role: 'REQ-PARTICIPANT' },
{ name: 'Brittany Seaton', email: '[email protected]', dir: 'https://linkedin.com/in/brittanyseaton', role: 'OPT-PARTICIPANT' }
]
}

Expand Down Expand Up @@ -60,8 +60,8 @@ ics.createEvent(event, (error, value) => {
// STATUS:CONFIRMED
// CATEGORIES:10k races,Memorial Day Weekend,Boulder CO
// ORGANIZER;CN=Admin:mailto:[email protected]
// ATTENDEE;RSVP=TRUE;CN=Adam Gibbons:mailto:[email protected]
// ATTENDEE;RSVP=FALSE;DIR=https://linkedin.com/in/brittanyseaton;CN=Brittany
// ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Adam Gibbons:mailto:[email protected]
// ATTENDEE;RSVP=FALSE;ROLE=OPT-PARTICIPANT;DIR=https://linkedin.com/in/brittanyseaton;CN=Brittany
// Seaton:mailto:[email protected]
// DURATION:PT6H30M
// END:VEVENT
Expand Down Expand Up @@ -216,7 +216,7 @@ The following properties are accepted:
| 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' }`
| attendees | Persons invited to the event | `[{ name: 'Mo', email: '[email protected]', rsvp: true }, { name: 'Bo', email: '[email protected]', dir: 'https://twitter.com/bo1234' }]`
| 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' }]`
| 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', trigger: [2000, 1, 4, 18, 30] }` OR `{ action: 'DISPLAY', trigger: { hours: 2, minutes: 30, before: true }` OR `{ action: 'DISPLAY', trigger: { hours: 2, minutes: 30, before: false }` OR `{ action: 'AUDIO', 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
3 changes: 2 additions & 1 deletion src/schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const contactSchema = Joi.object().keys({
name: Joi.string(),
email: Joi.string().email(),
rsvp: Joi.boolean(),
dir: Joi.string().uri()
dir: Joi.string().uri(),
partstat: Joi.string()
})

const organizerSchema = Joi.object().keys({
Expand Down
4 changes: 3 additions & 1 deletion src/utils/set-contact.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export default function setContact({ name, email, rsvp, dir }) {
export default function setContact({ name, email, rsvp, dir, partstat, role }) {
let formattedAttendee = ''
formattedAttendee += rsvp ? 'RSVP=TRUE;' : 'RSVP=FALSE;'
formattedAttendee += role ? `ROLE=${role};` : ''
formattedAttendee += partstat ? `PARTSTAT=${partstat};` : ''
formattedAttendee += dir ? `DIR=${dir};` : ''
formattedAttendee += 'CN='
formattedAttendee += name || 'Unnamed attendee'
Expand Down
40 changes: 40 additions & 0 deletions test/utils/set-contact.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@ import { expect } from 'chai'
import { setContact } from '../../src/utils'

describe('utils.setContact', () => {
it('set a contact with role', () => {
const contact = { name: 'm-vinc', email: '[email protected]' }
const contactChair = Object.assign({role: 'CHAIR'}, contact)
const contactRequired = Object.assign({role: 'REQ-PARTICIPANT' }, contact)
const contactOptional = Object.assign({role: 'OPT-PARTICIPANT' }, contact)
const contactNon = Object.assign({role: 'NON-PARTICIPANT' }, contact)
expect(setContact(contactChair))
.to.equal(`RSVP=FALSE;ROLE=CHAIR;CN=m-vinc:mailto:[email protected]`)
expect(setContact(contactRequired))
.to.equal(`RSVP=FALSE;ROLE=REQ-PARTICIPANT;CN=m-vinc:mailto:[email protected]`)
expect(setContact(contactOptional))
.to.equal(`RSVP=FALSE;ROLE=OPT-PARTICIPANT;CN=m-vinc:mailto:[email protected]`)
expect(setContact(contactNon))
.to.equal(`RSVP=FALSE;ROLE=NON-PARTICIPANT;CN=m-vinc:mailto:[email protected]`)
expect(setContact(contact))
.to.equal(`RSVP=FALSE;CN=m-vinc:mailto:[email protected]`)
})
it('set a contact with partstat', () => {
const contact = { name: 'm-vinc', email: '[email protected]' }
const contactUndefined = Object.assign({partstat: undefined}, contact)
const contactNeedsAction = Object.assign({partstat: 'NEEDS-ACTION'}, contact)
const contactAccepted = Object.assign({partstat: 'ACCEPTED'}, contact)
const contactDeclined = Object.assign({partstat: 'DECLINED'}, contact)
const contactTentative = Object.assign({contact, partstat: 'TENTATIVE'}, contact)

expect(setContact(contactUndefined))
.to.equal('RSVP=FALSE;CN=m-vinc:mailto:[email protected]')

expect(setContact(contactNeedsAction))
.to.equal('RSVP=FALSE;PARTSTAT=NEEDS-ACTION;CN=m-vinc:mailto:[email protected]')

expect(setContact(contactDeclined))
.to.equal('RSVP=FALSE;PARTSTAT=DECLINED;CN=m-vinc:mailto:[email protected]')

expect(setContact(contactTentative))
.to.equal('RSVP=FALSE;PARTSTAT=TENTATIVE;CN=m-vinc:mailto:[email protected]')

expect(setContact(contactAccepted))
.to.equal('RSVP=FALSE;PARTSTAT=ACCEPTED;CN=m-vinc:mailto:[email protected]')
})
it('sets a contact and defaults RSVP to false', () => {
const contact1 = {
name: 'Adam Gibbons',
Expand Down

0 comments on commit 43dbc4a

Please sign in to comment.