Class: Members::DestroyService

Inherits:
BaseService show all
Includes:
Gitlab::ExclusiveLeaseHelpers
Defined in:
app/services/members/destroy_service.rb

Constant Summary

Constants included from Gitlab::ExclusiveLeaseHelpers

Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::ExclusiveLeaseHelpers

#in_lock

Methods inherited from BaseService

#after_execute, #initialize

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from Members::BaseService

Instance Method Details

#execute(member, skip_authorization: false, skip_subresources: false, unassign_issuables: false, destroy_bot: false, skip_saml_identity: false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/members/destroy_service.rb', line 7

def execute(
  member,
  skip_authorization: false,
  skip_subresources: false,
  unassign_issuables: false,
  destroy_bot: false,
  skip_saml_identity: false
)

  unless skip_authorization
    raise Gitlab::Access::AccessDeniedError unless authorized?(member, destroy_bot)

    raise Gitlab::Access::AccessDeniedError if destroying_member_with_owner_access_level?(member) &&
      cannot_revoke_owner_responsibilities_from_member_in_project?(member)
  end

  @skip_auth = skip_authorization

  if a_group_owner?(member)
    process_destroy_of_group_owner_member(member, skip_subresources, skip_saml_identity)
  else
    destroy_member(member)
    destroy_data_related_to_member(member, skip_subresources, skip_saml_identity)
  end

  enqueue_jobs_that_needs_to_be_run_only_once_per_hierarchy(member, unassign_issuables)

  member
end

#mark_as_recursive_callObject

We use this to mark recursive calls made to this service from within the same service. We do this so as to help us run some tasks that needs to be run only once per hierarchy, and not recursively.



39
40
41
# File 'app/services/members/destroy_service.rb', line 39

def mark_as_recursive_call
  @recursive_call = true
end