Skip to content

Commit

Permalink
Add SENT-BY property to organizer (adamgibbons#230)
Browse files Browse the repository at this point in the history
* feat: add sent-by property to organizer

* feat: add sentBy to attributes table of README.md

---------

Co-authored-by: Adam Gibbons <[email protected]>
  • Loading branch information
employee451 and adamgibbons authored Feb 5, 2023
1 parent e2be11e commit 1306072
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ 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' }`
| 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' }]`
| 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' }`
Expand Down
4 changes: 3 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export type EventAttributes = {
status?: EventStatus;
busyStatus?: 'FREE' | 'BUSY' | 'TENTATIVE' | 'OOF';

organizer?: Person;
organizer?: Person & {
sentBy?: string;
};
attendees?: Attendee[];

categories?: string[];
Expand Down
3 changes: 2 additions & 1 deletion src/schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const contactSchema = yup.object().shape({
const organizerSchema = yup.object().shape({
name: yup.string(),
email: yup.string().email(),
dir: yup.string()
dir: yup.string(),
sentBy: yup.string()
}).noUnknown()

const alarmSchema = yup.object().shape({
Expand Down
5 changes: 3 additions & 2 deletions src/utils/set-organizer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export default function setOrganizer({ name, email, dir }) {
export default function setOrganizer({ name, email, dir, sentBy }) {
let formattedOrganizer = ''
formattedOrganizer += dir ? `DIR="${dir}";` : ''
formattedOrganizer += sentBy ? `SENT-BY="MAILTO:${sentBy}";` : ''
formattedOrganizer += 'CN='
formattedOrganizer += name || 'Organizer'
formattedOrganizer += email ? `:mailto:${email}` : ''
formattedOrganizer += email ? `:MAILTO:${email}` : ''

return formattedOrganizer
}
14 changes: 8 additions & 6 deletions test/pipeline/format.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
formatEvent,
buildEvent
} from '../../src/pipeline'
import {foldLine} from "../../src/utils";

describe('pipeline.formatEvent', () => {
it('writes default values when no attributes passed', () => {
Expand Down Expand Up @@ -206,12 +207,13 @@ describe('pipeline.formatEvent', () => {
expect(formattedEventAnyClass).to.contain('CLASS:non-standard-property')
})
it('writes an organizer', () => {
const event = formatEvent({ organizer: {
name: 'Adam Gibbons',
email: '[email protected]'
}})
const formattedEvent = formatEvent(event)
expect(event).to.contain('ORGANIZER;CN=Adam Gibbons:mailto:[email protected]')
const formattedEvent = formatEvent({ organizer: {
name: 'Adam Gibbons',
email: '[email protected]',
dir: 'test-dir-value',
sentBy: '[email protected]'
}})
expect(formattedEvent).to.contain(foldLine('ORGANIZER;DIR="test-dir-value";SENT-BY="MAILTO:[email protected]";CN=Adam Gibbons:MAILTO:[email protected]'))
})
it('writes an alarm', () => {
const formattedEvent = formatEvent({ alarms: [{
Expand Down

0 comments on commit 1306072

Please sign in to comment.