Class: Subscriptions::Ci::Pipelines::StatusesUpdated

Inherits:
BaseSubscription
  • Object
show all
Includes:
Gitlab::Graphql::Laziness
Defined in:
app/graphql/subscriptions/ci/pipelines/statuses_updated.rb

Constant Summary

Constants inherited from BaseSubscription

BaseSubscription::UNAUTHORIZED_ERROR_MESSAGE

Instance Method Summary collapse

Methods included from Gitlab::Graphql::Laziness

#defer, #force

Methods inherited from BaseSubscription

#initialize, #subscribe

Constructor Details

This class inherits a constructor from Subscriptions::BaseSubscription

Instance Method Details

#authorized?(project_id:) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
# File 'app/graphql/subscriptions/ci/pipelines/statuses_updated.rb', line 16

def authorized?(project_id:)
  project = force(GitlabSchema.find_by_gid(project_id))

  unauthorized! unless project
  unauthorized! unless Ability.allowed?(current_user, :read_pipeline, project)

  true
end

#update(project_id:) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/graphql/subscriptions/ci/pipelines/statuses_updated.rb', line 25

def update(project_id:)
  updated_pipeline = object

  return NO_UPDATE unless updated_pipeline

  project = force(GitlabSchema.find_by_gid(project_id))

  return NO_UPDATE unless project && updated_pipeline.project_id == project.id
  return NO_UPDATE unless Ability.allowed?(current_user, :read_pipeline, updated_pipeline)

  updated_pipeline
end