diff options
Diffstat (limited to 'app/workers/remove_expired_members_worker.rb')
-rw-r--r-- | app/workers/remove_expired_members_worker.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/workers/remove_expired_members_worker.rb b/app/workers/remove_expired_members_worker.rb index f56a6cd9fa2..35844fdf297 100644 --- a/app/workers/remove_expired_members_worker.rb +++ b/app/workers/remove_expired_members_worker.rb @@ -7,11 +7,19 @@ class RemoveExpiredMembersWorker # rubocop:disable Scalability/IdempotentWorker feature_category :authentication_and_authorization worker_resource_boundary :cpu + # rubocop: disable CodeReuse/ActiveRecord def perform - Member.expired.find_each do |member| + Member.expired.preload(:user).find_each do |member| Members::DestroyService.new.execute(member, skip_authorization: true) + + expired_user = member.user + + if expired_user.project_bot? + Users::DestroyService.new(nil).execute(expired_user, skip_authorization: true) + end rescue => ex logger.error("Expired Member ID=#{member.id} cannot be removed - #{ex}") end end + # rubocop: enable CodeReuse/ActiveRecord end |