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 webhook compatibility for calendar object events #51082

Merged
merged 2 commits into from
Mar 7, 2025

Conversation

edward-ly
Copy link
Contributor

@edward-ly edward-ly commented Feb 27, 2025

Summary

Adds webhook compatibility to event whenever a new calendar object (e.g. calendar event) is created via implementation of OCP\EventDispatcher\IWebhookCompatibleEvent.

TODO

Checklist

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Is this going to be a public API?

The events are in OCA, not OCP. There are no compatibility or stability guarantees in private app namespaces.

@edward-ly
Copy link
Contributor Author

edward-ly commented Feb 27, 2025

Is this going to be a public API?

The events are in OCA, not OCP. There are no compatibility or stability guarantees in private app namespaces.

Ah right, I forgot about that. So if webhooks can only listen to events in the public namespace, would adding a new namespace such as OCP\Calendar\Events and creating new events that extend the private ones be a viable solution?

EDIT: actually, in the webhook listeners documentation, there are some webhook events that are still in the OCA namespace, so I'm not sure if the workaround is really necessary.

@ChristophWurst
Copy link
Member

EDIT: actually, in the webhook listeners documentation, there are some webhook events that are still in the OCA namespace, so I'm not sure if the workaround is really necessary.

That is true and worrying to me, but on the other hand not my responsibility.

For caldav and carddav I will require a strict separation of private and public API, so we can continue to make easy modifications to internals, and have a solid, stable API for selected classes.

So yes, if these events are consumed by other apps, please move them to OCP. Do not extend private types from the public API. Just move them.

@ChristophWurst ChristophWurst marked this pull request as draft February 27, 2025 17:35
@ChristophWurst ChristophWurst added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Feb 27, 2025
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

See above. The goal of this PR is to expose a public API, which internal events aren't.

Thanks you for you contribution

@ChristophWurst ChristophWurst added the pending documentation This pull request needs an associated documentation update label Feb 27, 2025
@edward-ly edward-ly force-pushed the feat/dav/calendar-obj-event-webhooks branch from aa749d0 to 82477b8 Compare February 28, 2025 01:22
@AndyScherzinger AndyScherzinger added this to the Nextcloud 32 milestone Feb 28, 2025
@AndyScherzinger
Copy link
Member

/backport to stable31

@ChristophWurst
Copy link
Member

@AndyScherzinger are we backporting new APIs for this?

@edward-ly edward-ly force-pushed the feat/dav/calendar-obj-event-webhooks branch from 82477b8 to 7ee0155 Compare February 28, 2025 15:07
@AndyScherzinger
Copy link
Member

In this case yes, else the customer needs to wait until v32 enterprise.

@edward-ly
Copy link
Contributor Author

I think I have everything setup now, but let me know if I'm missing anything.

@edward-ly edward-ly requested a review from ChristophWurst March 3, 2025 16:12
@edward-ly edward-ly changed the title feat(dav): add webhook compatibility for calendar object events feat(dav): add webhook compatibility for calendar object created event Mar 3, 2025
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@tcitworld
Copy link
Member

My 2 cents: I get the customer specific need, but it would be nice to have all events (not just calendar object creation) at the same time targeting the same API level.

@ChristophWurst
Copy link
Member

I'm not sure I get your message. Do you mean also moving/exposing the other calendar events?

@edward-ly edward-ly requested review from Altahrim, sorbaugh and come-nc and removed request for a team March 4, 2025 16:38
@edward-ly
Copy link
Contributor Author

Added the remaining events for the calendar objects now, will get to the documentation shortly.

@edward-ly edward-ly changed the title feat(dav): add webhook compatibility for calendar object created event feat(dav): add webhook compatibility for calendar object events Mar 4, 2025
@edward-ly edward-ly force-pushed the feat/dav/calendar-obj-event-webhooks branch 2 times, most recently from 86fd59c to 38ec4cc Compare March 6, 2025 18:11
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@st3iny st3iny left a comment

Choose a reason for hiding this comment

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

We are gonna break some apps I think. But it's fine as the OCA stuff is not a public API.

@edward-ly edward-ly force-pushed the feat/dav/calendar-obj-event-webhooks branch from 38ec4cc to dee1d4f Compare March 7, 2025 16:10
@edward-ly edward-ly changed the title feat(dav): add webhook compatibility for calendar object events feat(dav)!: add webhook compatibility for calendar object events Mar 7, 2025
@edward-ly edward-ly merged commit 06119ed into master Mar 7, 2025
190 checks passed
@edward-ly edward-ly deleted the feat/dav/calendar-obj-event-webhooks branch March 7, 2025 16:42
@come-nc come-nc added 4. to release Ready to be released and/or waiting for tests to finish and removed 2. developing Work in progress labels Mar 10, 2025
@come-nc
Copy link
Contributor

come-nc commented Mar 10, 2025

We are gonna break some apps I think. But it's fine as the OCA stuff is not a public API.

Still, make sure that it’s part of the ugrade guide for apps.

@tcitworld
Copy link
Member

Seeing this remark on the above mentioned issue by @JonathanTreffler

it is a bit weird to have such generically named public events, that are actually fixed to the default calendar backend and therefore not as generic as the name would suggest

That's correct, OCP events should be able to be emitted by any app (not just DAV\CalendarBackend). To distinguish between those, maybe we should reference the calendar provider class inside events as well?

@come-nc
Copy link
Contributor

come-nc commented Mar 10, 2025

Seeing this remark on the above mentioned issue by @JonathanTreffler

it is a bit weird to have such generically named public events, that are actually fixed to the default calendar backend and therefore not as generic as the name would suggest

Is that theoritical or are there other calendar backends out there?
Why would another calendar backend not fire the OCP events?

@ChristophWurst
Copy link
Member

Is that theoritical or are there other calendar backends out there?

Not many, but https://github.com/nextcloud/deck/blob/0223dd9a3a50838a202f3c68ed714e80b00dd2ae/lib/DAV/CalendarPlugin.php#L16 for example.

@JonathanTreffler
Copy link

Is that theoritical or are there other calendar backends out there?

Currently not many, but I sure hope we some day have an equivalent to groupfolders for calendars (so basicaly calendars that are not owned by any user but are global to the system). (And unless somebody else starts that project before I get to it I plan on being the person who writes that)

@JonathanTreffler
Copy link

JonathanTreffler commented Mar 10, 2025

Why would another calendar backend not fire the OCP events?

Yes they could, but what are they going to put in as calendarId ? Unlike files where the fileIds are unique in the filecache globally no matter which app mounted it in the filesystem AFAIK calendars are only uniquely addressable over their principalUri + uri and the id is an implementation detail of the provider and not unique (please somebody correct me if I got that wrong 😆 ).

(In dav_push we stopped referencing calendars by principalUri + uri and instead now reference calendars by provider name + id, because those are the same no matter from which users perspective you look at it (for example a shared calendar has a different uri from the perspective of the user shared to, but the same id))

@AndyScherzinger
Copy link
Member

Hi @JonathanTreffler not sure if it went unnoticed but due to #51331 this change will also become active in a 31 when merged and shipped, since I can't wait to for 32 due to customer needs.

While I can judge if there is a non-breaking way for Nc31? @ChristophWurst

@JonathanTreffler
Copy link

Hi @JonathanTreffler not sure if it went unnoticed but due to #51331 this change will also become active in a 31 when merged and shipped, since I can't wait to for 32 due to customer needs.

While I can judge if there is a non-breaking way for Nc31? @ChristophWurst

Thank you for making me aware of that, i totally missed the backport.

I am going to look into hooking into the the old or new events depending on what is available, but if that is not possible I think it would also be fine to require the latest release of 31 for dav_push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish feature: dav pending documentation This pull request needs an associated documentation update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants