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: OCC and OCS Calendar Import/Export #6596

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SebastianKrupinski
Copy link
Contributor

Summary

This adds the ability to export calendars via the OCS and OCC.

OCS

Endpoint: /ocs/v2.php/calendar/export
Request: GET/POST
{
"id": "personal",
"fmt": "xcal", (optional "ical, jcal, xcal", defaults to "ical")
"user": "user1" (optional admin permissions required)
}

OCC

Command: calendar:export
Arguments: userId calendarId format (optional) filepath

TODO

  • Tests

Checklist

Copy link

codecov bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 23.20%. Comparing base (e2a85a4) to head (37b3bc2).
Report is 5 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6596      +/-   ##
============================================
- Coverage     23.40%   23.20%   -0.21%     
- Complexity      472      510      +38     
============================================
  Files           249      252       +3     
  Lines         11901    12004     +103     
  Branches       2282     2279       -3     
============================================
  Hits           2786     2786              
- Misses         8788     8891     +103     
  Partials        327      327              
Flag Coverage Δ
javascript 14.85% <ø> (+<0.01%) ⬆️
php 56.84% <ø> (-2.62%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tcitworld
Copy link
Member

I think it feels odd to have this in the calendar as other calendar commands are into the dav namespace.

Comment on lines +68 to +70
'jcal' => '["vcalendar",[["version",{},"text","2.0"],["prodid",{},"text","-\/\/IDN nextcloud.com\/\/Calendar App\/\/EN"]],[',
'xcal' => '<?xml version="1.0" encoding="UTF-8"?><icalendar xmlns="urn:ietf:params:xml:ns:icalendar-2.0"><vcalendar><properties><version><text>2.0</text></version><prodid><text>-//IDN nextcloud.com//Calendar App//EN</text></prodid></properties><components>',
default => "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//IDN nextcloud.com//Calendar App//EN\n"
Copy link
Member

Choose a reason for hiding this comment

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

I don't like hardcoding things here. Would it be possible to serialize an empty calendar to get the start string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, I don't like hard coding this either. But I could not think of a better way to do this.

Yes, I could serialize a empty object but then I would still have to do fancy string manipulations to separate the beginning form the closing. Then output the beginning, then the objects, then the closing, as the output is a generated stream directly to the http buffer.

The only way to do this without hard coding would be to generate the calendar in memory and serialize it all as one. So it was a trade of hard coding or php memory exhaustion when exporting large calendars.

@SebastianKrupinski
Copy link
Contributor Author

I think it feels odd to have this in the calendar as other calendar commands are into the dav namespace.

I wasn't sure where we wanted to put this, as the code can export any calendar, from any calendar provider, so its not just for DAV, it can easily be moved to server code. I will ask about it once CW is back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress
Projects
Status: 🏗️ In progress
Development

Successfully merging this pull request may close these issues.

2 participants