Google Meet: receive Meet events on a server route

Merged
EH
20h ago
+259-0

Context

Follows https://github.com/twentyhq/twenty/pull/30611 in the Google Meet app series started in https://github.com/twentyhq/twenty/pull/30587.

Every piece is merged: a subscription per connected Google account (https://github.com/twentyhq/twenty/pull/30604), the check of the Pub/Sub push token (https://github.com/twentyhq/twenty/pull/30607), the event parsing (https://github.com/twentyhq/twenty/pull/30611) and the function that queues the import for an event (https://github.com/twentyhq/twenty/pull/30610). This PR only wires them behind a server route, which completes the push path: Google event, Pub/Sub push, Twenty route, import.

What this PR does

  • Adds the google-meet-events-resolver logic function with a server route trigger (POST, authorization forwarded). A Pub/Sub push subscription delivers every workspace's events to this one URL. The file is 90 lines and contains no new logic of its own, only the calls below.
  • It answers 503 while the audience or the service account is not configured, and 401 unless isGooglePubsubPushAuthorized accepts the request's token, so nothing is accepted unauthenticated.
  • It reads the event with parseGoogleMeetEventOrThrow, finds the workspace holding the server-scope claim on the event's subscription, and dispatches to google-meet-handle-event there.
  • A message that is not a Google Workspace event, or whose subscription no workspace claims, is acknowledged with 200 and skipped, so Pub/Sub does not retry it forever. Unreadable event data and a token that could not be checked both throw, so Pub/Sub retries.
  • Adds two required server variables: GOOGLE_MEET_PUBSUB_AUDIENCE and GOOGLE_MEET_PUBSUB_SERVICE_ACCOUNT_EMAIL.

Follow-ups in this series

  • A daily job that renews the subscriptions and catches up on calls whose event was missed.
  • The setup guide for the Google Cloud project, the Pub/Sub topic, the push subscription and these settings.

Checks

  • yarn lint, yarn typecheck, yarn test:unit (141 tests) and twenty app build pass locally.
  • Not run: integration tests (they need a running server, CI runs them), and no real Pub/Sub push was received. The end-to-end path needs a Google Cloud project with the topic and push subscription and will be tested with a real account once this is merged.