Class: Subscriptions::Notes::Base

Inherits:
BaseSubscription
  • Object
show all
Includes:
Gitlab::Graphql::Laziness
Defined in:
app/graphql/subscriptions/notes/base.rb

Direct Known Subclasses

Created, Deleted, Updated

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?(noteable_id:) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
# File 'app/graphql/subscriptions/notes/base.rb', line 12

def authorized?(noteable_id:)
  noteable = force(GitlabSchema.find_by_gid(noteable_id))

  # unsubscribe if user cannot read the noteable anymore for any reason, e.g. issue was set confidential,
  # in the meantime the read note permissions is checked within its corresponding returned type, i.e. NoteType
  unauthorized! unless noteable && Ability.allowed?(current_user, :"read_#{noteable.to_ability_name}", noteable)

  true
end