2016-08-04 17:34:57 -04:00
|
|
|
module Members
|
|
|
|
class AuthorizedDestroyService < BaseService
|
|
|
|
attr_accessor :member, :user
|
|
|
|
|
|
|
|
def initialize(member, user = nil)
|
|
|
|
@member, @user = member, user
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2016-08-18 16:32:42 -04:00
|
|
|
return false if member.is_a?(GroupMember) && member.source.last_owner?(member.user)
|
|
|
|
|
2016-08-04 17:34:57 -04:00
|
|
|
member.destroy
|
|
|
|
|
|
|
|
if member.request? && member.user != user
|
|
|
|
notification_service.decline_access_request(member)
|
|
|
|
end
|
2016-09-09 12:51:31 -04:00
|
|
|
|
|
|
|
member
|
2016-08-04 17:34:57 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|