adamgibbons / ics

iCalendar (ics) file generator for node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RRULE placed after VALARM section

bishift opened this issue · comments

Hello, I am currently having the following issue :

When I set a RRULE, it is placed at the very bottom of the VEVENT section, Outlook doesn't process properly the event recurrency.

To have Outlook processing it properly, the RRULE must be placed before the VALARM section (this is not documented, I just figured it out)

I create an ics file using these parameters :

const invitation = await createCalendarEvent({
      organizer,
      start,
      end,
      title,
      recurrenceRule: "FREQ=WEEKLY;BYDAY=TU;INTERVAL=1;COUNT=5",
      method: "REQUEST",
      location: "My Test Name",
      categories: ["My Test Name"],
      description: "This is my event description",
    });

The file obtained has a misplaced RRULE statement. Well it is actually correctly placed if we consider it should be anywhere inside the VEVENT section BUT it does not work with Outlook. it is at the very end of the VEVENT section, which makes the recipient unable to take RRULE into account.

So basically Outlook will be unable to handle this properly. BTW I tried with gmail/google agenda and it works fine ;-)

Here is the ics file I get :

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:adamgibbons/ics
METHOD:REQUEST
X-PUBLISHED-TTL:PT1H
BEGIN:VEVENT
UID:g9Oc0jw7aRV4zXLl9FjXp
SUMMARY:test ics 7
DTSTAMP:20220223T164800Z
DTSTART:20220223T194800Z
DTEND:20220223T204800Z
DESCRIPTION:This is my event description
LOCATION:My Test Name
CATEGORIES:My Test Name
ORGANIZER;CN=John Doe:mailto:john.doe@organization.org
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT30M
END:VALARM
RRULE:FREQ=WEEKLY;BYDAY=TU;INTERVAL=1;COUNT=5 // ---> this should not be here :-(
END:VEVENT
END:VCALENDAR

Here is what we should get in order to schedule properly the event :

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:adamgibbons/ics
METHOD:REQUEST
X-PUBLISHED-TTL:PT1H
BEGIN:VEVENT
UID:g9Oc0jw7aRV4zXLl9FjXp
RRULE:FREQ=WEEKLY;BYDAY=TU;INTERVAL=1;COUNT=5 // ---> this definitely should be here :-)
SUMMARY:test ics 7
DTSTAMP:20220223T164800Z
DTSTART:20220223T194800Z
DTEND:20220223T204800Z
DESCRIPTION:This is my event description
LOCATION:My Test Name
CATEGORIES:My Test Name
ORGANIZER;CN=John Doe:mailto:john.doe@organization.org
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT30M
END:VALARM
END:VEVENT
END:VCALENDAR

@bishift, I opened a PR to fix this issue because it also affects me (#220). But in case you're still looking for a solution so many months later I'll share with you (and anyone else affected) my temporary fix I used that utilizes regex:

https://gist.github.com/TiE23/8c59eb7185ecc1ece9f002d684c95653

I also include unit tests showing that it works.

Just take the iCal string that createEvent()/createEvents() returns and process it through this function and it'll do its magic and Outlook will be happy again.

It works because it assumes the current behavior of this module that the last three elements of data are VALARM, RRULE, and DURATION in that order. As you can see here.