From bd3425b389c6990f5c96e939249c383bdade29ee Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Thu, 23 Apr 2020 16:26:29 -0600 Subject: [PATCH] REFACTOR: Use rescue inside do/end block Follow up to 9cbbaf4237e2343348f5d0a7375796e6712b4580 --- app/services/user_updater.rb | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/app/services/user_updater.rb b/app/services/user_updater.rb index cdd5203f969..02db79cb95c 100644 --- a/app/services/user_updater.rb +++ b/app/services/user_updater.rb @@ -149,26 +149,24 @@ class UserUpdater saved = nil - begin - User.transaction do - if attributes.key?(:muted_usernames) - update_muted_users(attributes[:muted_usernames]) - end + User.transaction do + if attributes.key?(:muted_usernames) + update_muted_users(attributes[:muted_usernames]) + end - if attributes.key?(:ignored_usernames) - update_ignored_users(attributes[:ignored_usernames]) - end + if attributes.key?(:ignored_usernames) + update_ignored_users(attributes[:ignored_usernames]) + end - name_changed = user.name_changed? - 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 = user.name_changed? + if (saved = (!save_options || user.user_option.save) && user_profile.save && user.save) && + (name_changed && old_user_name.casecmp(attributes.fetch(:name)) != 0) - StaffActionLogger.new(@actor).log_name_change( - user.id, - old_user_name, - attributes.fetch(:name) { '' } - ) - end + StaffActionLogger.new(@actor).log_name_change( + user.id, + old_user_name, + attributes.fetch(:name) { '' } + ) end rescue Addressable::URI::InvalidURIError => e # Prevent 500 for crazy url input