CoderDojo / community-platform

Zen, the CoderDojo Community Platform!
https://zen.coderdojo.com
MIT License
121 stars 55 forks source link

ICS event subscription #1246

Closed niccokunzmann closed 5 years ago

niccokunzmann commented 5 years ago

I am building a calendar based on the events. I would like to subscribe to the events via an ICS link. I think, this is not yet implemented.

How would one go about it to implement this? Which parts of the code should be touched?

Another place would be to use an external service. The API already exports enought information about the events so that an external service would suffice. If the external service is a node service, this makes is easier to integrate the code later.

Which way would you prefer?

Wardormeur commented 5 years ago

Hey Nicco There are a couple of PR to work on this already, the main issue being timezone: without it, the ICS will be invalid. So the main requirement before that is to be able to save the timezone of the event, and the only source we use (which isn't reliable) is the creator's one (the champion, when saving the event); and considering we were regarding the rework of event creation, I delayed the change. Another way would be to use the event's location, which means mapping the address to it's region's timezone. I would prefer an internal service (but this haven't been really discussed), simply because it allows us to make use of it from the emails easily (without storing a reference as we can reuse the eventId) and purge the images when we wishes to. Existing work on it : https://github.com/Wardormeur/ics-to-s3 https://github.com/CoderDojo/cp-zen-platform/pull/1258 Changes for the cp-local-development's docker-compose:

  s3:
    image: andrewgaul/s3proxy
    entrypoint: 
      - sh
      - -c
      - "{ sleep 5 && echo -e \"PUT http://localhost:80/zenbookingqrcode HTTP/1.0\\n\\n\" | nc localhost 80; } & sh /opt/s3proxy/run-docker-container.sh"
    environment:
      - S3PROXY_AUTHORIZATION=none
    ports:
      - 8099:80
  ics:
    image: node:carbon
    command: yarn dev
    working_dir: /usr/src/app
    volumes:
      - ./workspace-zen/services/ics-generator:/usr/src/app:Z

If you wish to extend my PR, feel free to, or you can build your own :) I'll be happy to help in both cases

niccokunzmann commented 5 years ago

Another way would be to use the event's location, which means mapping the address to it's region's timezone.

That would be good, I think. I as a creator could be in a different time zone or use a different browser at the same location at the moment I create the event. However, people going to the dojo usually assume the dojo to advertise its time in the local time.

A short workaround would be what I have seen in the discourse events plugin. You pass the time zone as a parameter. Usually, a dojo does not change the time zone as it does not travel across borders, barely in the city. So, the parameter can be set in the url as the dojo is set in the url.

Wardormeur commented 5 years ago

The scenarios I thought of so far were :

niccokunzmann commented 5 years ago

I think of these use-cases

All other use-cases can be mapped to this one. I would think that this is a nice question to give to the community to vote for, e.g. a random sample of people subscribed to the platform.

I do not think it is much useful for one event as this is work over and over again.

embedded with the "new event" notification email I do not like this mail. It is on by default and we sent out hundreds of mails in advance for events in e.g. June. This changed the communication pattern. So, I do not use it and thus I can not make a statement for usage.

On 2/27/19 10:38 AM, Wardormeur wrote:

The scenarios I thought of so far were :

  • embedded with the "new event" notification email
  • available through the GUI to "add to your calendar" at the end of the booking flow (parents/mentor)
  • available through the GUI "somewhere" (?) for champions as a personal reminder Mind if I ask you "how" you would see it being used ? The reason I'm asking that is that "if" we skip the embedded, making it as part of the GET events endpoint as a different representation is the most logical answer; but that excludes the most used of our parent communication channel (even though it can be at the end of the booking flow).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CoderDojo/community-platform/issues/1246#issuecomment-467792560, or mute the thread https://github.com/notifications/unsubscribe-auth/AAieIOVpAc5_AytHtYe65oD7ddv2fF2yks5vRlIMgaJpZM4bPsMW.

Wardormeur commented 5 years ago

Fair feedback regarding the emails (cc @conoramurphy ) I like the idea of the whole planning thing, basically an exportable version of /dashboard/my-tickets? My original idea was based upon static file as there is very few needs to change the file (create once and reuse), but I can see a simpler version being easier (passing down the tz on request as you said) if we export it from the GUI (as a first implementation that is, email can follow on once we have the TZ on save of the event). The main issue I could foresee in all those scenario is the freshness of the data. Without a proper auth scheme, that means we can't subscribe to the .ics. I guess that's an acceptable risk? Cancelled event are notified by email? On other points: applications(/orders which are a grouping of tickets on the new booking flow) awaiting approval should.. not be exported by default or should be very clear that you're not accepted yet?

Wardormeur commented 5 years ago

Hey @niccokunzmann I think your solution to not generate a static file is actually better. The reason for that is ICS supports information like the attendants : that would let us to have a richer export of the event . I started a simple version over there : https://github.com/CoderDojo/events-service/pull/27. There is still work to use the tz, work with a list of events and such; but overall rather happy to we have a better solution :)

niccokunzmann commented 5 years ago

The main issue I could foresee in all those scenario is the freshness of the data.

Hm. My calendar (Thunderbird) GETs the ICS file every one hour. I think that is expected.

Without a proper auth scheme, that means we can't subscribe to the .ics.

I think, it is ok to subscribe to one dojo. I also think, we could make several issues for this: one minimal working prototype and other extensions to it.

MWP: ICS event export with time zone as parameter, manually set, for a dojo. The event contains a link to the event page.

On other points: applications(/orders which are a grouping of tickets on the new booking flow) awaiting approval should.. not be exported by default or should be very clear that you're not accepted yet?

For the minimal solution, no-one expects their attendance to the written to it. It is only for notification about dojo events in your own calendar.

Wardormeur commented 5 years ago

So, there's an issue: the ics package doesn't support timezone apparently. (https://github.com/adamgibbons/ics/issues/52) I'll look into implementing it, at least a basic version, in the ics package but we could try without TZ and see how each provider works in term of import : does it take the user's/system TZ ? if so, that could simplify our deployment for a MVP version. The issue will be for event near time zone change (DST a-like) and for events in the far future.

Wardormeur commented 5 years ago

Added the PRs for the API server and the frontend

niccokunzmann commented 5 years ago

I implemented ical event unfolding in Python https://github.com/niccokunzmann/python-recurring-ical-events. As I read your message, I remember: time zones are not a requirement for dates. I.e. I have seen this in this Calendar http://www.officeholidays.com/ics/ics_country_noregion.php?tbl_country=Germany.

DTSTART;VALUE=DATE:20080101 DTEND;VALUE=DATE:20080102

Wardormeur commented 5 years ago

That's actually a different implementation :) That means the date is stored as a floating time (https://www.w3.org/International/wiki/FloatingTime)

The "TZID" property parameter MUST NOT be applied to DATE
      properties and DATE-TIME or TIME properties whose time values are
      specified in UTC.

      The use of local time in a DATE-TIME or TIME value without the
      "TZID" property parameter is to be interpreted as floating time,
      regardless of the existence of "VTIMEZONE" calendar components in
      the iCalendar object.

What I was wrong at, though, is to assume a UTC date should need a timezone. I'll revert that, and I think we can give it a go ?

Wardormeur commented 5 years ago

Apart from the missing endpoint for the URL attribute (which I'm unsure how it's being used) which I haven't been able to understand the use for (both google calendar and gnome-calendar ignore it, so it might be either an .ics, or anything else?), I think it's production ready. if @conoramurphy and (@DanielBrierton @ArayB or @nyashamaphosa) could have a look, that'd be great :) Cheers; W.

Wardormeur commented 5 years ago

PRs to be reviewed are the following : https://github.com/CoderDojo/cp-local-development/pull/82 https://github.com/CoderDojo/cp-zen-frontend/pull/248 https://github.com/CoderDojo/cp-zen-platform/pull/1351 https://github.com/CoderDojo/events-service/pull/27

Wardormeur commented 5 years ago

Done and gone :)

niccokunzmann commented 5 years ago

@Wardormeur Thanks for the implementation. How can I test this? How you be sure this can be closed? What is the user story behind this?

Here is one:

User Story 1

When I go to a dojo page https://zen.coderdojo.com/dojos/de/brandenburg/potsdam/potsdam-hpi, I would like to see a calendar symbol. When I click on this symbol, A download link opens for an ICS file The download link looks like https://zen.coderdojo.com/dojos/de/brandenburg/potsdam/potsdam-hpi.ics

User Story 2

When I log into zen and I click on my user name on the top right corner then, I click on My Events When the page loads, Then, I see a link "Subscribe with a Calendar" pointing to the ICS file

Wardormeur commented 5 years ago

Hey Nicco :) It's on the left column of the Dojo page, under "Time" Edit cause I read too fast: So right now, it only supports the first user story. If we see some usage, or anybody wants to work on it, the 2nd one could be done too ;)

niccokunzmann commented 5 years ago

It's on the left column of the Dojo page, under "Time"

Ohhhhh. It is not blue!! O.O Erm, I mean, I tested it as a user who erm is not so fluent in viewenig web pages ;)

niccokunzmann commented 5 years ago

Thanks for the reply!

niccokunzmann commented 5 years ago

I think, making it blue can be a user story for first-timers

niccokunzmann commented 5 years ago

https://github.com/CoderDojo/community-platform/issues/1256