cuny-academic-commons / bp-event-organiser

Allows Event Organiser plugin events to be assigned to BuddyPress groups and generates a group calendar page for each group
GNU General Public License v2.0
3 stars 1 forks source link

Attach ICS to outgoing BPGES single emails. #68

Open boonebgorges opened 5 years ago

boonebgorges commented 5 years ago

See #66.

This was surprisingly easy to do! The one trick is getting the contents of the .ics file. EO's ical.php template will only work properly with WP's routing system (have_posts(), is_single(), etc), so it's not straightforward to generate the .ics programatically. The two options I saw were (a) fake the globals and load the template, or (b) make an HTTP request to get the ICS. The latter option seems (barely) less error-prone to me.

Note the hoops you've got to jump through: I filter ass_send_email_args because it's the most convenient place to determine whether we're looking at a BPEO item, and then I conditionally hook to phpmailer_init.

Email client integration works seamlessly, which is very cool.

@r-a-y As the resident expert on ical, could you have a look at the above, and let me know whether you have a better idea about how to work around the limitations of ical generation?

r-a-y commented 5 years ago

Hmm, the external ping technique is neat, but I worry about private events. How does that work? I see you try to pass the $_COOKIE variable, but does that work effectively especially when GES now uses a queue-based system that doesn't rely on a logged-in user.

boonebgorges commented 5 years ago

The queue processes should always contain the $_COOKIE - it's always sent with the async process, and is daisy-chained for each batch - but you're right that this could use a closer look.

A modified approach might be to fetch the ical a single time, then save it to a file.

This would all be easier if EO's ical-generation was not so context-sensitive. I wonder if Stephen would accept a PR that abstracts it.

boonebgorges commented 5 years ago

I just ran a couple quick tests with private groups and it does appear to work, but this could use some verification. Maybe I'll throw this up on the CUNY Academic Commons and see if we can get some real world testing.