Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dav): Add an API for upcoming events #45435

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

ChristophWurst
Copy link
Member

@ChristophWurst ChristophWurst commented May 22, 2024

Summary

Expose a convenience endpoint to query upcoming events. Events can be filtered by location to match Talk conversation URLs.

Demo / how to test

$ curl -u admin:admin -X GET 'https://localhost/ocs/v1.php/apps/dav/api/v1/events/upcoming?location=https%3A%2F%2Flocalhost%2Fcall%2Fqkcxuuge' -H "OCS-APIRequest: true"
<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>100</statuscode>
  <message>OK</message>
  <totalitems></totalitems>
  <itemsperpage></itemsperpage>
 </meta>
 <data>
  <events>
   <element>
    <uri>133A0EF2-15FA-46C3-9BB6-FA3629A94437.ics</uri>
    <recurrenceId/>
    <calendarUri>personal</calendarUri>
    <start>1723646700</start>
    <summary>Y</summary>
    <location>https://localhost/call/qkcxuuge</location>
    <calendarAppUrl>https://localhost/apps/calendar/</calendarAppUrl>
   </element>
  </events>
 </data>
</ocs>

TODO

  • PoC
  • Possible timezone handling
  • Code clean-up
  • Tests
  • API docs

Checklist

@ChristophWurst
Copy link
Member Author

@DorraJaouad could you please check the API and tell me if there is any more info we need to expose?

@DorraJaouad
Copy link

In order to generate the url to calendar app with event details open in sidebar, we need to have start timestamp and calendar id. However, the calendar id in url doesn't seem to match the one provided in this API point when testing. so is it missing ?

@ChristophWurst
Copy link
Member Author

The API exposes the numeric (internal) calendar ID. The calendar app uses the calendar URI. I will change the API to expose the URI here as well 👍

@ChristophWurst
Copy link
Member Author

@DorraJaouad is the API usable from your perspective?

@DorraJaouad
Copy link

so this is the response so far

            "events": [
                {
                    "uri": "3F1F3474-0B83-4DA0-8E75-A10F5350A16D.ics",
                    "recurrenceId": null,
                    "calendarUri": "personal",
                    "start": 1723680000,
                    "summary": "Party",
                    "location": "https:\/\/nextcloud.local\/index.php\/call\/66kq5sfv",
                    "calendarAppUrl": "https:\/\/nextcloud.local\/index.php\/apps\/calendar\/"
                }

I believe recurrenceId is the the calendar URI (to be used in url) ?

@ChristophWurst
Copy link
Member Author

The recurrence id is useful for repeating events. I think it's best if you use calendarAppUrl for the "deep" link. It's not fully deep yet but a good starting point. Building the URL yourself opens the door for problems once the calendar URL format changes

@ChristophWurst ChristophWurst marked this pull request as ready for review August 13, 2024 15:17
@ChristophWurst ChristophWurst added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Aug 13, 2024
@ChristophWurst ChristophWurst force-pushed the feat/dav/upcoming-events-api branch from 4d56826 to 0984dae Compare August 13, 2024 15:33
@ChristophWurst ChristophWurst mentioned this pull request Aug 13, 2024
@ChristophWurst ChristophWurst force-pushed the feat/dav/upcoming-events-api branch from 0984dae to b7d848c Compare August 13, 2024 15:57
@ChristophWurst
Copy link
Member Author

Excuse the force push. Tests were failing 😬

Comment on lines +55 to +58
'events' => array_map(fn (UpcomingEvent $e) => $e->jsonSerialize(), $this->service->getEvents(
$this->userId,
$location,
)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

smoof 😍

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
@ChristophWurst ChristophWurst force-pushed the feat/dav/upcoming-events-api branch from b7d848c to 370a9d7 Compare August 13, 2024 18:03
@ChristophWurst
Copy link
Member Author

Another force push for cs fixes

@SebastianKrupinski
Copy link
Contributor

Tested.

Case 1: Blank Location
Result: Returns events from personal and shared calendar

Case 2: Location matching a location in a event
Result: Returns events for specific location from personal and shared calendars

Case 2: Location partially matching the location of another event
Result: Returns any events that have similar location string (this is probably unwanted behavior)

image

@ChristophWurst ChristophWurst merged commit 7641e76 into master Aug 14, 2024
169 checks passed
@ChristophWurst ChristophWurst deleted the feat/dav/upcoming-events-api branch August 14, 2024 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews feature: dav
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants