mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
26 lines
561 B
Ruby
26 lines
561 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class BulkUserTitleUpdate < ::Jobs::Base
|
|
UPDATE_ACTION = 'update'
|
|
RESET_ACTION = 'reset'
|
|
|
|
def execute(args)
|
|
new_title = args[:new_title]
|
|
granted_badge_id = args[:granted_badge_id]
|
|
action = args[:action]
|
|
badge = Badge.find(granted_badge_id) rescue nil
|
|
|
|
return unless badge # Deleted badge protection
|
|
|
|
case action
|
|
when UPDATE_ACTION
|
|
badge.update_user_titles!(new_title)
|
|
when RESET_ACTION
|
|
badge.reset_user_titles!
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|