Class: Members::DestroyService

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

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

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) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/services/members/destroy_service.rb', line 5

def execute(member, skip_authorization: false, skip_subresources: false, unassign_issuables: false, destroy_bot: false)
  raise Gitlab::Access::AccessDeniedError unless skip_authorization || authorized?(member, destroy_bot)

  @skip_auth = skip_authorization

  return member if member.is_a?(GroupMember) && member.source.last_owner?(member.user)

  member.destroy

  member.user&.invalidate_cache_counts

  if member.request? && member.user != current_user
    notification_service.decline_access_request(member)
  end

  delete_subresources(member) unless skip_subresources
  delete_project_invitations_by(member) unless skip_subresources
  enqueue_delete_todos(member)
  enqueue_unassign_issuables(member) if unassign_issuables

  after_execute(member: member)

  member
end