diff --git a/src/pipeline/format.js b/src/pipeline/format.js index 02349b92..e42920e2 100644 --- a/src/pipeline/format.js +++ b/src/pipeline/format.js @@ -65,7 +65,8 @@ export function formatEvent(attributes = {}) { classification, created, lastModified, - htmlContent + htmlContent, + recurrenceId } = attributes let icsFormat = '' @@ -111,6 +112,8 @@ export function formatEvent(attributes = {}) { icsFormat += setAlarm(alarm) }) } + icsFormat += recurrenceId ? foldLine(`RECURRENCE-ID:${encodeNewLines(formatDate(recurrenceId))}`) + "\r\n" : ""; + icsFormat += `END:VEVENT\r\n` return icsFormat diff --git a/src/schema/index.js b/src/schema/index.js index d6508842..5e810896 100644 --- a/src/schema/index.js +++ b/src/schema/index.js @@ -110,7 +110,8 @@ const eventShape = { created: dateTimeSchema({ required: false }), lastModified: dateTimeSchema({ required: false }), exclusionDates: yup.array().of(dateTimeSchema({ required: true })), - htmlContent: yup.string() + htmlContent: yup.string(), + recurrenceId : dateTimeSchema({ required: false }) } const headerAndEventSchema = yup.object().shape({ ...headerShape, ...eventShape }).test('xor', `object should have end or duration (but not both)`, val => { diff --git a/test/pipeline/format.spec.js b/test/pipeline/format.spec.js index 353ac743..489f9d3c 100644 --- a/test/pipeline/format.spec.js +++ b/test/pipeline/format.spec.js @@ -327,4 +327,16 @@ describe('pipeline.formatEvent', () => { }) expect(formattedEvent).to.contain('EXDATE:20000620T010000Z,20000621T010000Z') }) + it("writes recurrence ID", () => { + const event = { + uid:"uid", + title: "Test Event", + start: [2023, 5, 15, 10, 0], + end: [2023, 5, 15, 11, 0], + recurrenceId: [2023, 5, 15, 10, 0], + }; + + const result = formatEvent(event); + expect(result).to.contain("RECURRENCE-ID:20230515T100000Z"); + }); })