2015-03-06 16:44:54 -05:00
|
|
|
class UsernameChanger
|
|
|
|
|
2017-07-27 21:20:09 -04:00
|
|
|
def initialize(user, new_username, actor = nil)
|
2015-03-06 16:44:54 -05:00
|
|
|
@user = user
|
|
|
|
@new_username = new_username
|
|
|
|
@actor = actor
|
|
|
|
end
|
|
|
|
|
2017-07-27 21:20:09 -04:00
|
|
|
def self.change(user, new_username, actor = nil)
|
2015-03-06 16:44:54 -05:00
|
|
|
self.new(user, new_username, actor).change
|
|
|
|
end
|
|
|
|
|
|
|
|
def change
|
2017-02-27 15:02:00 -05:00
|
|
|
if @actor && @user.username != @new_username
|
2015-03-06 16:44:54 -05:00
|
|
|
StaffActionLogger.new(@actor).log_username_change(@user, @user.username, @new_username)
|
|
|
|
end
|
|
|
|
|
|
|
|
# future work: update mentions and quotes
|
|
|
|
|
|
|
|
@user.username = @new_username
|
|
|
|
@user.save
|
|
|
|
end
|
|
|
|
end
|