Google Meet: renew subscriptions and catch up on missed calls daily

EH
20h ago
+375-6

Context

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

The push path is complete: Google event, Pub/Sub push, Twenty route, import. Two things still need a schedule, both raised in the review of https://github.com/twentyhq/twenty/pull/30604: Google expires an event subscription after 7 days, and an event can be missed (a delivery Pub/Sub gave up on, a subscription that was down). This PR adds the daily job that covers both.

What this PR does

  • Adds the google-meet-refresh-connections logic function on a daily cron (23 3 * * *). For every connected Google account that can still sign in, it queues two existing functions:
    • google-meet-register-connection, the connect hook, which renews the account's subscription or recreates it;
    • google-meet-queue-conference-imports, which lists the account's recent calls and queues one import per call. The import is an upsert, so a call the push already imported is only refreshed.
  • The cron handler only enqueues, with one random delay of up to an hour, because every workspace runs the cron at the same minute. Job ids carry the connection and the day, so a repeated tick does not queue the work twice.
  • Widens the recent-call window of google-meet-queue-conference-imports from 6 to 50 hours. It is now called once a day and skips calls that are still running. Such a call started at most 24 hours before the run, and the next run is at most 25 hours later, so 50 hours guarantees the next run finds it.
  • A subscription Google suspended is deleted and recreated instead of renewed, since renewing does not resume it.

Checks

  • yarn lint, yarn typecheck, yarn test:unit (149 tests) and twenty app build pass locally.
  • Not run: integration tests (they need a running server, CI runs them), and nothing was renewed against the real Google API. That a renewed subscription stays suspended is taken from Google's documentation, which has a separate reactivate call, and was not observed.