nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
26.69k stars 4k forks source link

Push sync for calendars, tasks, and contacts (CalDAV and CardDAV) #22379

Open aniqueta opened 4 years ago

aniqueta commented 4 years ago

Is your feature request related to a problem? Please describe. Nextcloud is clearly maturing fast. Thanks to everyone for the hard work. To bring it to parity with other first class cloud services, it would be awesome if Nextcloud could provide push notifications for CalDAV and CardDAV. Changes to calendars and tasks would benefit from faster propagation without needing to resort to rapid fetch intervals, which are resource intensive. It's frustrating when changes across devices are not in sync and create version control issues when editing on multiple devices.

It appears to be possible to enable push for CalDAV and CardDAV on Apple iOS, iPadOS, and macOS devices. Not sure about other devices.

Describe the solution you'd like Implement something like this from FastMail. Unclear what the technical backend is. Perhaps they would be willing to share. For iOS, iPadOS, and macOS, it appears this involved collaboration with Apple, although not sure. https://fastmail.blog/2016/10/10/push-sync-for-contacts-calendars-now-available-on-ios/

Describe alternatives you've considered Faster fetch intervals are imperfect, drain resources (especially for battery powered devices. Z-push is an option but clunky and also resource intensive. It is inefficient, since it just converts CalDAV and CardDAV to Microsoft ActiveSync. This also creates reliance on a new protocol.

Thanks again, and completely understand that this is "nice to have" not "need to have." But, given how Nextcloud is maturing, it would be awesome to bring it to parity with cloud services others offer.

tcitworld commented 4 years ago

Not sure about what Apple's push for *DAV refers to but the only close thing to work with that we've got is this 3-year old first version of an IETF draft : https://tools.ietf.org/html/draft-gajda-dav-push-00.

Maybe it refers to this Apple's CalendarServer extension for Discovery of CalDAV Push-Notification Settings, but since Apple abandoned CalendarServer, not sure this is a safe bet.

Asking Fastmail for their technical details would indeed be a first step, but I'm thinking since they are working on JMAP Calendars, not sure they did go this way.

Anyway, I've not heard of any other clients supporting this, so it would be quite useless for non-Apple users for a while.

jakobroehrl commented 4 years ago

I don't like pull sync as it is now neither. For android you need Davx5 to sync CalDAV and CardDAV. And there a Live/Push sync is not possible: https://forums.bitfire.at/topic/2201/live-sync-possible/2?_=1598341471130

rfc2822 commented 4 years ago

In theory, that could be done over OpenPush (see https://gitlab.com/bitfireAT/davx5-ose/-/wikis/Roadmap#other-ideas). But then

So I'd not expect this for the near future...

szaimen commented 3 years ago

@nextcloud/server-triage is this feasible?

tcitworld commented 3 years ago

The development of OpenPush seems to have stalled, and none of the other things mentioned did change, including no client changes.

Note that there's now a JMAP app for Nextcloud https://github.com/audriga/nextcloud-jmap.

jvican commented 3 years ago

I don't think Fastmail is using JMAP Calendars to send notifications to iOS because the Apple integration uses CalDAV and I doubt Fastmail's CalDAV server speaks JMAP with Apple servers.

I'm going to reach out to Fastmail to learn more about how they are actually doing it. Will report back when I know more about it, in case this information is still of interest to you.

aniqueta commented 3 years ago

@jvican Thanks for thinking of that. Sorry I neglected to reply here, but I worked through Fastmail support to reach a dev. Here's what they shared.

We had some personal contacts at Apple from our standards work. They were able to organise a meeting for us, and from there we were given the necessary certificates and protocol details to implement IMAP push. Later, when implemented CalDAV and CardDAV, we asked and were given access to push for those too. Unfortunately I can't give you any names, though I can say that most of them have since moved on from Apple.

The actual protocol we implement is documented at https://github.com/apple/ccs-calendarserver/blob/master/doc/Extensions/caldav-pubsubdiscovery.txt. I understand that it was at one time possible to extract the necessary certs from Apple's server products, though I've never seen it done. I'm not sure now if there's another way to get hold of them except directly from Apple.

There are still (unsupported) ways to get the necessary push notification certificates from Apple. For example: scintill/macos-server-apns-certs freswa/dovecot-xaps-daemon

@tcitworld Is it possible to reopen this issue and explore some of the above? I think there are no other viable paths forward for push notification for Apple platforms otherwise?

tcitworld commented 3 years ago

That's a great piece of information !

We shouldn't need mangling with Apple's certificate, and possibly could just reuse the push proxy used by the Nextcloud notification app (which, if we use it, will need adjustments to send custom payloads https://github.com/nextcloud/notifications/issues/1055, otherwise put this directly in dav).

The form of the registration is flexible enough to have transports of other types, for instance DAVdroid could support type="FCM" (Google Firebase) or type="OpenPush" or type="UnifiedPush" (see https://unifiedpush.org). @rfc2822

Even better, we could do WebPush in the browser to tell the calendar to refresh itself (instead of https://github.com/nextcloud/calendar/issues/31).

<push-transports xmlns='http://calendarserver.org/ns/'>
  <transport type='APSD'>
    <subscription-url>
      <href xmlns='DAV:'>https://server.example.com:8443/apns</href>
    </subscription-url>
    <apsbundleid>com.apple.calendar.XServer.934668ca-125e-4246-afee-8cf2df37aab8</apsbundleid>
    <env>PRODUCTION</env>
    <refresh-interval>172800</refresh-interval>
  </transport>
</push-transports>

There's more investigation needed, and the lack of documentation will be a pain in the ass, but this is exciting.

rfc2822 commented 3 years ago

@tcitworld We're very interested in getting push (over both Google and open protocols) to CalDAV/CardDAV/DAVx5. I will have a a look at this.

ghost commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions.

jokerigno commented 2 years ago

any update on this? It would be great if changes will be sync quickly.

karmanyaahm commented 2 years ago

The form of the registration is flexible enough to have transports of other types, for instance DAVdroid could support type="FCM" (Google Firebase) or type="OpenPush" or type="UnifiedPush" (see https://unifiedpush.org). @rfc2822

Even better, we could do WebPush in the browser to tell the calendar to refresh itself (instead of nextcloud/calendar#31).

WebPush and UnifiedPush are (practically) API compatible, so supporting WebPush (using one of the many existing libraries) for browsers means automatically supporting UnifiedPush for Android clients on the server-side

aniqueta commented 1 year ago

@tcitworld I was excited to see this get tagged as a feature to develop about a year ago. Is this still in something we can expect? Or better to look elsewhere for CalDAV (and CardDAV) push? Thanks.

tcitworld commented 1 year ago

Well, a long as someone's not paying Nextcloud GmbH for development, this depends on volunteer work (possibly mine). So it could come anytime between soon or never. There's still interest for this from a user and developer point of vue anyway.

Or better to look elsewhere for CalDAV (and CardDAV) push?

I don't know of any other FLOSS project working on this, but feel free to check. Fastmail could well also be the only service in the world doing push over CalDAV, as the rest of the ecosystem may have moved to private APIs and/or JMAP. Maybe some of the people at CalConnect know.

shane64 commented 1 year ago

Just an orphaned former Mac OS Server user without the skills or resources to engage in this work hoping to find a way to continue to self-host calendar data (with push notifications to my iOS devices) and hoping that connecting someone here on the NextCloud CalDAV side with someone familiar with Apple Push Notifications side might see some magic happen.

https://github.com/freswa/dovecot-xaps-daemon/issues/20#issuecomment-1246028895

Thanks.

devvv4ever commented 1 year ago

We planning to start working on this pretty soon! For this we've teamed up with @verdigado who are interested in bringing this to life on the Nextcloud side, and we will implement it in DAVx5 for Android. We've also had a basic talk about this with @ChristophWurst and @st3iny at Nextcloud conf'22 and it seems that there is general interest in extending Nextclouds PUSH capabilities :)

aniqueta commented 1 year ago

Great to hear @devvv4ever. A clarifying question from your message in November: Is the focus of the near-term work just Android (DAVx5)? Thanks.

devvv4ever commented 1 year ago

The current project plan is:

Working on the standard will probably start in March (this is the hardest of all these parts since it has to be developed very well and many parties are involved)

aniqueta commented 1 year ago

Thanks. So iOS/iPadOS and macOS are not in the first phase of this plan?

devvv4ever commented 1 year ago

Thats something we can't directly influence. We'll try however to activate connections to the Apple people (via CalConnect) to get them in on this during creating/forming the standard (which is the requirement for all other steps). They need to implement the standard on their iClouds CalDAV/CardDAV connectors so that this can be of use then. If that happens you should also be able to receive instant push notifications on Android via DAVx5 when a collection on the server (for example a calendar on the icloud server) has changed.

aniqueta commented 1 year ago

I see. So the approach described above for Apple devices won't be pursued or that's part of this approach? https://github.com/nextcloud/server/issues/22379#issuecomment-889702369

Would Z-Push be the best path forward for push on Apple devices then?

shane64 commented 1 year ago

What about combining the approach for push notifications originally taken in Apple's original open source CalDAV server (http://www.calendarserver.org/) and with the approach taken to patch the dovecot code to use Apple's new HTTP/2 push notification API (https://github.com/freswa/dovecot-xaps-daemon)? Automatic APNS certificate generation and renewal (that used to be taken care of by macOS Server) is included in the second project (which will give you native push notifications with iOS's calendar app (and the macOS one). If it can be done for dovecot, why not nextcloud's CalDAV implementation?

WhyNotHugo commented 1 year ago

There's been some discussion on creating an extension to caldav for push mechanisms on a separate issue tracker.

This separate discussion originally started out between myself (vdirsyncer maintainer) and some of the DAVx5 devs, since we both want push updates on the client side (although on different platforms).

IMHO, it seems that using caldav-pubsubdiscovery.txt as a base with Web Push is the best fit. Replacing APN-specific properties with WebPush-specific ones should suffice for this use case, while using APN (apple's notification protocol) as a non-normative/de-facto variation will result in things working properly on Apple's ecosystem.

If someone is willing to work on a server-side of this, I'm pretty confident that I can address a client side implementation (e.g.: for vdirsyncer) in the coming months.

tcitworld commented 1 year ago

I have started to look at details of the implementation in Nextcloud. The aim is have at least WebPush (all of RFC 8030, RFC 8291 and RFC 8292) for the NC Web Calendar app and another push provider (probably UnifiedPush as it's closest) working.

Implementation details are:

On collection changes, we add a new listener for already existing events that lists registered providers for the user and sends notifications to the subscription URLs.

Other than that, we also need to explore how handle expired subscriptions (make sure every provider have a receipts concept and return appropriate error messages if subscription is expired).

¹ Obviously, you'll still need API keys (and eventually payment) for those. ² Meaning possibly bypassing the NC Push Proxy for regular if you have another provider… and client apps are made compatible

provokateurin commented 1 year ago

There is already work on the webpush part: https://github.com/nextcloud/notifications/issues/1225 cc @karmanyaahm @Zocker1999NET