Add YouTube webhooks and Google Calendar webhooks#214
Merged
Conversation
…and improve error messaging
…scription verification
…eo monitoring and interaction
…reaction validation
…webhook_receiver functions
…adjust required fields
…e and adjust published_after logic
…et_or_create method
- Added GoogleWebhookWatch model to track active push notification subscriptions for Gmail, Calendar, and YouTube. - Created views for handling incoming push notifications from Google services. - Implemented tasks for setting up and renewing Google watches. - Updated celery beat schedule to include tasks for renewing Google watches and setting up YouTube subscriptions. - Added helper functions for managing Google push notifications. - Created migrations for the new GoogleWebhookWatch model. - Updated URLs to include endpoints for Google webhooks.
…n_config function
…e subscription verification
…lify method calls
…ce code readability
…ssage_matches_action function
…me_max calculation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive YouTube integration support to the automation platform, including webhook-based push notifications for real-time video updates. The implementation leverages Google OAuth for authentication and introduces YouTube actions (new video monitoring, channel stats, video search) and reactions (post comment, add to playlist, rate video).
Key changes:
- Added YouTube service with 3 actions and 3 reactions for video automation
- Implemented Google webhook infrastructure for Gmail, Calendar, and YouTube push notifications
- Created database model for tracking Google webhook watches with automatic renewal
- Updated OAuth configuration to include YouTube scopes
Reviewed Changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| mobile/lib/utils/service_token_mapper.dart | Maps YouTube service to Google OAuth token |
| frontend/src/pages/ServiceDetail.tsx | Adds YouTube to OAuth providers and displays webhook banner |
| frontend/src/pages/Debug.tsx | Simplified webhook trigger text |
| frontend/src/components/GoogleWebhookBanner.tsx | New component displaying webhook status for Google services |
| backend/users/oauth_views.py | Auto-triggers Google webhook setup after OAuth connection |
| backend/scripts/test_google_webhooks.py | Infrastructure test script for Google webhooks |
| backend/automations/webhooks.py | Added YouTube webhook verification and event extraction |
| backend/automations/validators.py | Added YouTube action/reaction schemas and improved error messages |
| backend/automations/urls.py | Registered dedicated Google webhook endpoints |
| backend/automations/tasks.py | Added YouTube/Calendar polling tasks and Google watch management |
| backend/automations/serializers.py | Updated service configuration with YouTube logo and OAuth mapping |
| backend/automations/models.py | New GoogleWebhookWatch model for tracking push notification subscriptions |
| backend/automations/migrations/0012_google_webhook_watch.py | Migration for GoogleWebhookWatch model |
| backend/automations/management/commands/init_services.py | YouTube service definition with actions/reactions |
| backend/automations/helpers/youtube_helper.py | YouTube Data API v3 helper functions |
| backend/automations/helpers/google_webhook_helper.py | Google webhook creation/management utilities |
| backend/automations/helpers/gmail_helper.py | Added history API support for Gmail webhooks |
| backend/automations/helpers/calendar_helper.py | Added calendar_id parameter for multi-calendar support |
| backend/automations/google_webhook_views.py | Dedicated webhook receivers for Gmail/Calendar/YouTube |
| backend/area_project/settings/base.py | YouTube OAuth scopes and webhook configuration |
| backend/area_project/celery.py | Scheduled tasks for watch renewal and YouTube subscriptions |
| .env.example | Formatting fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant enhancements to Google service integrations, focusing on enabling and managing push notifications (webhooks) for Gmail, Google Calendar, and YouTube. It adds new environment-based configuration options, expands OAuth scopes, introduces helper functions for managing Google watches, and updates Celery beat scheduling to support webhooks and watch renewals. The changes improve efficiency by reducing reliance on polling and providing robust support for push-based event handling.
Google Webhook (Push Notification) Support:
google_webhook_helper.pywith helper functions to create, stop, and renew push notification watches for Gmail, Calendar, and YouTube, including support for PubSubHubbub for YouTube. This enables the backend to manage Google push notifications more effectively.base.pyto enable/disable webhooks for Gmail, Calendar, and YouTube, configure webhook URLs, and set watch renewal intervals.base.pyto include YouTube read-only and force-ssl permissions, required for YouTube webhook support.Celery Beat Scheduling Updates:
celery.pyto:Helper Function Improvements:
get_historyfunction togmail_helper.pyto fetch Gmail history changes since a specific history ID, supporting efficient processing of push notification events.list_upcoming_eventsfunction incalendar_helper.pyto allow querying a specific calendar ID, improving flexibility for multi-calendar scenarios. [1] [2] [3]Configuration and Environment:
BACKEND_URLsetting tobase.pyfor use as the webhook callback endpoint, supporting both development and production environments.These changes lay the foundation for robust, scalable, and efficient event-driven integrations with Google services by leveraging push notifications and reducing unnecessary polling.