Class: Gitlab::SidekiqMiddleware::AdminMode::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/sidekiq_middleware/admin_mode/client.rb

Overview

Checks if admin mode is enabled for the request creating the sidekiq job by examining if admin mode has been enabled for the user If enabled then it injects a job field that persists through the job execution

Instance Method Summary collapse

Instance Method Details

#call(_worker_class, job, _queue, _redis_pool) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gitlab/sidekiq_middleware/admin_mode/client.rb', line 10

def call(_worker_class, job, _queue, _redis_pool)
  return yield unless ::Feature.enabled?(:user_mode_in_session)

  # Admin mode enabled in the original request or in a nested sidekiq job
  admin_mode_user_id = find_admin_user_id

  if admin_mode_user_id
    job['admin_mode_user_id'] ||= admin_mode_user_id

    ::Gitlab::AppLogger.debug("AdminMode::Client injected admin mode for job: #{job.inspect}")
  end

  yield
end