Class: SchedulerAuthCheckWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/scheduler_auth_check_worker.rb

Overview

Daily health check for scheduler OAuth connections.

Runs at 7am Chicago time. For each active scheduler profile:

  • Google Calendar: checks via TimeOffRequests::GoogleAuthService
  • Zoom: uses Zoom::OauthService#healthy? which attempts a token refresh
    before calling the API — avoids false positives from expired access tokens

Emails the employee only if a connection is truly dead (refresh failed).

Instance Method Summary collapse

Instance Method Details

#performObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/workers/scheduler_auth_check_worker.rb', line 17

def perform
  SchedulerProfile.where(scheduler_enabled: true).includes(:employee).find_each do |profile|
    employee = profile.employee
    next unless employee&.

    issues = []

    gcal_status = TimeOffRequests::GoogleAuthService.check_status(employee, skip_api_check: false)
    issues << :google_calendar if gcal_status[:needs_reconnect]

    zoom_service = Zoom::OauthService.new(account: employee.)
    if zoom_service.connected?
      issues << :zoom unless zoom_service.healthy?
    end

    next if issues.empty?

    InternalMailer.scheduler_auth_expired(employee, issues).deliver_now
  end
end