user name changes: don't create feedback or modaction.

Don't create a neutral feedback, create a mod action, or dmail the user
after changing a user's name. The name change is already recorded in
/user_name_change_requests, so creating feedbacks and mod actions is
redundant. They also expose private information (when a user deletes
their account, old name changes aren't supposed to be visible any more).
This commit is contained in:
evazion
2019-09-25 21:39:01 -05:00
parent c710aa3ffb
commit 07f706e75f
2 changed files with 9 additions and 51 deletions

View File

@@ -6,7 +6,7 @@ class UserNameChangeRequest < ApplicationRecord
validates :desired_name, user_name: true
validates_presence_of :original_name, :desired_name
after_create :approve!
after_create :update_name!
def self.visible(viewer = CurrentUser.user)
if viewer.is_admin?
@@ -18,12 +18,8 @@ class UserNameChangeRequest < ApplicationRecord
end
end
def approve!
user.update_attribute(:name, desired_name)
body = "Your name change request has been approved. Be sure to log in with your new user name."
Dmail.create_automated(:title => "Name change request approved", :body => body, :to_id => user_id)
UserFeedback.create(:user_id => user_id, :category => "neutral", :body => "Name changed from #{original_name} to #{desired_name}")
ModAction.log("Name changed from #{original_name} to #{desired_name}",:user_name_change)
def update_name!
user.update!(name: desired_name)
end
def not_limited