[MlMt] RSVP/respond to ical/.ics calendar invite?
Benny Kjær Nielsen
mailinglist at freron.com
Fri Nov 3 05:42:16 EDT 2017
On 18 Oct 2017, at 19:03, Benny Kjær Nielsen wrote:
> On 17 Oct 2017, at 23:18, Giovanni Lanzani wrote:
>
>> - the attachment (i.e. the invite);
>
> This is where you need me to add something to MailMate. I've kind of
> postponed providing attachments to bundle commands until it was
> needed, but this is a “chicken or the egg” type of excuse :)
>
> I'm thinking this would be some kind of boolean option for bundle
> commands which would provide paths to all attachments saved as files
> (maybe optionally filtered by mime type). I'll need a bit of time to
> think about this.
>
> [...]
>
> But MailMate is also lacking the ability to let you add an attachment
> to a reply. This I would also need to add (and I would want to do this
> not only for the purpose of this bundle).
>
> [...]
>
> Maybe I should just let you know when the attachments features
> described above are available? :)
Ok, I've got something for you now in the latest test release of
MailMate.
First, a `*.mmCommand` file now recognizes a new key named
`filesPattern`. This is a regular expression which can be used to tell
MailMate which parts of an email to match. When iterating through the
so-called MIME parts of a message then it keeps track of the hierarchy
of MIME types. For example, a plaint text part might be:
multipart/mixed multipart/alternative text/plain
A pattern matching this would just be:
text/plain
If one wanted to only make it match when the message is nothing but a
plain text part then it would be:
^text/plain
In your case you just need to add this to the `mmCommand`:
filesPattern = "text/calendar";
This results in any `text/calendar` parts to be saved in temporary files
and the paths are provided using `MM_FILES` in the environment
variables. They are passed with some additional information in a JSON
array. Here's an example how one could work with that in ruby:
~~~ruby
#!/usr/bin/ruby -w
require 'json'
input=ENV["MM_FILES"]
files = JSON.parse(input)
attachments = []
files.each { |file|
attachments.push(file["filePath"]);
}
~~~
You can then parse the calendar file and do whatever is needed. If a
reply needs to be generated then you can return a set of actions. This
can also be done using JSON (which is a new feature). Here's an example:
~~~ruby
action = {
:type => "replyMessage",
:body => "This is a reply including an attachment...",
:temporaryAttachments => [ "/path/to/another/text/calendar/file.ics"
],
:resultActions => [ { :type => "openMessage" } ],
}
actions = { :actions => [ action ] }
puts actions.to_json
~~~
Note that `temporaryAttachments` means that MailMate takes
responsibility for deleting the files when it's done with them. Using
`attachments` instead means that MailMate won't delete them.
A remaining problem here might be that it's not sufficient to attach the
calendar file since that'll result in an email with the following
structure:
multipart/mixed
text/plain
text/calendar
It might not work in other email clients if the structure is not:
multipart/alternative
text/plain
text/calendar
This is all work-in-progress.
By the way, when working with iCalendar files then note that there's a
validator available [here](https://icalendar.org/validator.html).
--
Benny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freron.com/pipermail/mailmate/attachments/20171103/07040b4e/attachment-0001.html>
More information about the mailmate
mailing list