lpil / icalendar

🗓️ A small library for reading and writing ICalendar files.
MIT License
103 stars 56 forks source link

Add support for arbitrary calendar headers #56

Open nickgartmann opened 3 years ago

nickgartmann commented 3 years ago

In order to get a calendar invite sent via email to show RSVP buttons, the ics file must contain a METHOD header which matches the method provided in the Content-Type header of its file attachment (See the first paragraph of the iMIP RFC: https://datatracker.ietf.org/doc/html/rfc6047#section-2.4)

This can be achieved by inserting the headers manually after the ics has been generated, but this PR adds support for arbitrary headers to be added below the PRODID header.

nickgartmann commented 3 years ago

After some research of other libs, it looks like they call them properties but also there is a finite list of properties that are supported (per: https://datatracker.ietf.org/doc/html/rfc5545#section-3.7). They are:

You have everything but METHOD already in there, so maybe instead of adding headers I should just add method as an optional param in to_ics/1? I could also add the option to set CALSCALE and VERSION manually

lpil commented 3 years ago

That could work, though is it clear? What does the Ruby library do there?

nickgartmann commented 3 years ago

They define the settable properties manually and then loop through all of the calendar properties when serializing

They call the property ip_method - they had it as method but changed it in 2014 - I suspect this change was driven to minimize confusion with ruby meta programming naming conventions. Ruby prefers the name method over functions since you can't have a standalone function not attached to an object. The reasoning here is a guess though because the commit messages don't talk about the change at all and there was not a PR that drove the change.