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

Add webhook support #1718

Merged
merged 6 commits into from
Nov 23, 2021
Merged

Conversation

Lyncredible
Copy link
Contributor

Summary

Note: this is a new PR that addresses a compile-time deprecation warning that caused #1626 to be reverted.
This change adds webhook support to enable real-time syncing of remote updates. It takes advantage of the webhooks functionality provided by Microsoft. This fixes #1620.

How does it work

  1. The onedrive process stands up a local web server to receive incoming notifications (to be sent by Microsoft)
  2. The onedrive process registers the public-facing url of the web server with Microsoft, via the POST /subscriptions endpoint.
  3. When there is an remote update, Microsoft sends a notification request to the pre-registered url.
  4. The onedrive process receives the notification request, and kicks off a new delta sync loop to fetch updates.

Code changes

  1. onedrive.d contains the bulk of logic to manage the local web server and to register/renew subscriptions with Microsoft. It is also responsible for processing incoming notification requests. When such requests are received, it sends signals to the main sync loop.
  2. main.d contains the logic to process incoming signals and execute delta sync to fetch updates.
  3. The embeded web server is made possible via cgi.d from adamdruppe/arsd
  4. New config options are added to config.d and also documented.

Testing

Unfortunately I could only test this manually with a very straightforward setup: personal OneDrive account with no shared folders. More testing is welcome!

What is next

Currently the public-facing url has to be statically configured. This should work well for most users either with static public IP or with dynamic DNS services. We could consider adding UPnP support to allow dynamic configuration via automatic port forwarding.

@Lyncredible Lyncredible mentioned this pull request Nov 23, 2021
@abraunegg abraunegg added this to the v2.4.14 milestone Nov 23, 2021
@abraunegg abraunegg merged commit 1e2827a into abraunegg:master Nov 23, 2021
@abraunegg
Copy link
Owner

@Lyncredible
Thanks for resubmitting the PR and fixing the issue

@github-actions
Copy link

github-actions bot commented Dec 1, 2021

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Webhook integration for real-time remote OneDrive updates
2 participants