summaryrefslogtreecommitdiff
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 15:09:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 15:09:30 +0000
commitc6b3ec3f56fa32a0e0ed3de0d0878d25f1adaddf (patch)
tree967afee9a510ff9dd503ebd83706dc760ec2e3ed /app/models/user.rb
parent903ccf7c93eb9490c76857bffe744249cc07de09 (diff)
downloadgitlab-ce-c6b3ec3f56fa32a0e0ed3de0d0878d25f1adaddf.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb21
1 files changed, 8 insertions, 13 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 68c52751804..42972477d97 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -23,6 +23,7 @@ class User < ApplicationRecord
include BatchDestroyDependentAssociations
include HasUniqueInternalUsers
include IgnorableColumns
+ include UpdateHighestRole
DEFAULT_NOTIFICATION_LEVEL = :participating
@@ -238,7 +239,6 @@ class User < ApplicationRecord
end
end
end
- after_commit :update_highest_role, on: [:create, :update]
after_initialize :set_projects_limit
@@ -1854,20 +1854,15 @@ class User < ApplicationRecord
last_active_at.to_i <= MINIMUM_INACTIVE_DAYS.days.ago.to_i
end
- # Triggers the service to schedule a Sidekiq job to update the highest role
- # for a User
- #
- # The job will be called outside of a transaction in order to ensure the changes
- # for a Member to be commited before attempting to update the highest role.
- # rubocop: disable CodeReuse/ServiceClass
- def update_highest_role
- return unless (previous_changes.keys & %w(state user_type ghost)).any?
+ def update_highest_role?
+ return false unless persisted?
- run_after_commit_or_now do
- Members::UpdateHighestRoleService.new(id).execute
- end
+ (previous_changes.keys & %w(state user_type ghost)).any?
+ end
+
+ def update_highest_role_attribute
+ id
end
- # rubocop: enable CodeReuse/ServiceClass
end
User.prepend_if_ee('EE::User')