REFACTOR: Use rescue inside do/end block

Follow up to 9cbbaf4237
This commit is contained in:
Blake Erickson 2020-04-23 16:26:29 -06:00
parent 9f52997be1
commit bd3425b389
1 changed files with 15 additions and 17 deletions

View File

@ -149,26 +149,24 @@ class UserUpdater
saved = nil saved = nil
begin User.transaction do
User.transaction do if attributes.key?(:muted_usernames)
if attributes.key?(:muted_usernames) update_muted_users(attributes[:muted_usernames])
update_muted_users(attributes[:muted_usernames]) end
end
if attributes.key?(:ignored_usernames) if attributes.key?(:ignored_usernames)
update_ignored_users(attributes[:ignored_usernames]) update_ignored_users(attributes[:ignored_usernames])
end end
name_changed = user.name_changed? name_changed = user.name_changed?
if (saved = (!save_options || user.user_option.save) && user_profile.save && user.save) && if (saved = (!save_options || user.user_option.save) && user_profile.save && user.save) &&
(name_changed && old_user_name.casecmp(attributes.fetch(:name)) != 0) (name_changed && old_user_name.casecmp(attributes.fetch(:name)) != 0)
StaffActionLogger.new(@actor).log_name_change( StaffActionLogger.new(@actor).log_name_change(
user.id, user.id,
old_user_name, old_user_name,
attributes.fetch(:name) { '' } attributes.fetch(:name) { '' }
) )
end
end end
rescue Addressable::URI::InvalidURIError => e rescue Addressable::URI::InvalidURIError => e
# Prevent 500 for crazy url input # Prevent 500 for crazy url input