diff options
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 21 |
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') |