diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-22 18:09:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-22 18:09:31 +0300 |
commit | 06d4ce7ee0c0f9cf84a6799d97f64dd710d6e9f6 (patch) | |
tree | 6c975e5931ee5655f2aa9dbb0c087604d513ec5a /app/workers | |
parent | cea25900b73fcb7029845eeca5e5a9170349f1dd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/remove_expired_members_worker.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/app/workers/remove_expired_members_worker.rb b/app/workers/remove_expired_members_worker.rb index 35844fdf297..fc2ec047e1c 100644 --- a/app/workers/remove_expired_members_worker.rb +++ b/app/workers/remove_expired_members_worker.rb @@ -2,20 +2,29 @@ class RemoveExpiredMembersWorker # rubocop:disable Scalability/IdempotentWorker include ApplicationWorker - include CronjobQueue # rubocop:disable Scalability/CronWorkerContext + include CronjobQueue feature_category :authentication_and_authorization worker_resource_boundary :cpu # rubocop: disable CodeReuse/ActiveRecord def perform - Member.expired.preload(:user).find_each do |member| - Members::DestroyService.new.execute(member, skip_authorization: true) + Member.expired.preload(:user, :source).find_each do |member| + context = { + user: member.user, + # The ApplicationContext will reject type-mismatches. So a GroupMemeber will only populate `namespace`. + # while a `ProjectMember` will populate `project + project: member.source, + namespace: member.source + } + with_context(context) do + Members::DestroyService.new.execute(member, skip_authorization: true) - expired_user = member.user + expired_user = member.user - if expired_user.project_bot? - Users::DestroyService.new(nil).execute(expired_user, skip_authorization: true) + if expired_user.project_bot? + Users::DestroyService.new(nil).execute(expired_user, skip_authorization: true) + end end rescue => ex logger.error("Expired Member ID=#{member.id} cannot be removed - #{ex}") |