mustang-im / mustang

Mustang - New full-featured desktop email, chat and video conference client
https://mustang.im
Other
5 stars 0 forks source link

Calendar: Invitations in emails #68

Open benbucksch opened 3 weeks ago

benbucksch commented 3 weeks ago

We need to parse .ics attachments and iTIP, iMIP RFCs in incoming emails, read the event information out of it, and allow the user to add it to the calendar.

When we read an email, we need to notice that it has a calendar invitiation, parse it, and ask the user whether to add it to the calendar and whether to confirm the acknowlegment of the event to the sender. Similar to Thunderbird.

You need 2 preconditions for that: a) a code point where you can hook up your processing code. This will be the same point where we do mail "filtering" and and spam filtering (which both doesn't exist yet). Please make suggestions where you think are good hookup points.

b) UI and UI hookup to show the invitation data and the user response buttons. I am imaging this to show above the attachments. As API, we will have an .event property on the email object. You can populate this property with an ICSEvent object. The UI will show automatically once the .event property is populated. I will implement the UI once the parsing is implemented.

NeilRashbrook commented 2 weeks ago

Because PostalMIME doesn't have specific handling for invitations, it typically drops the text/calendar alternative on the floor. However, by keeping a reference to the PostalMIME object itself, we can easily check to see whether it found a text/calendar part, and if so, check its internal data structures to see whether it was an invitation.

Since we need to extract the method anyway, the proof of concept code I wrote in branch text-calendar simply puts the method and calendar part into additional fields in the email table.

The proof of concept code uses the ical.js library to parse the calendar part into a JavaScript object. I'm not exactly sure what the format of this object is so I haven't tried to convert it into an Event object yet.

benbucksch commented 2 weeks ago

Hey Neil, I've made a few review comments. The most important is that EMail.event should return a Mustang Event, not an ical.js data type, and that we shouldn't add the columns to the email database table. Is there a quick way how you can fix those 2 main issues, without too much work?

benbucksch commented 2 weeks ago

Can you please create new class ICSEvent (in logic/Calendar/ICS/ICSEvent), inheriting from Event, and a method fromICS(), which accepts the ICS and parses it using ical.js and sets the properties?