diff --git a/app/components/members/row_component.rb b/app/components/members/row_component.rb index 5820e45f88a..a6139f23741 100644 --- a/app/components/members/row_component.rb +++ b/app/components/members/row_component.rb @@ -50,8 +50,7 @@ module Members end def mail - return unless user? - return if principal.pref.hide_mail + return unless user? && current_user.allowed_globally?(:view_user_email) link = mail_to(principal.mail) diff --git a/app/components/users/profile/attributes_component.html.erb b/app/components/users/profile/attributes_component.html.erb index f6dac59e953..6714b4d58aa 100644 --- a/app/components/users/profile/attributes_component.html.erb +++ b/app/components/users/profile/attributes_component.html.erb @@ -4,7 +4,7 @@ component_wrapper do flex_layout do |details_container| - if @user.pref.can_expose_mail? + if current_user.allowed_globally?(:view_user_email) details_container.with_row(font_weight: :bold) do User.human_attribute_name(:mail) end diff --git a/app/components/users/profile/attributes_component.rb b/app/components/users/profile/attributes_component.rb index 5470dbc83d6..e7f7be0cf5a 100644 --- a/app/components/users/profile/attributes_component.rb +++ b/app/components/users/profile/attributes_component.rb @@ -40,7 +40,7 @@ module Users end def render? - @user.pref.can_expose_mail? || @user.visible_custom_field_values.any? { _1.value.present? } + current_user.allowed_globally?(:view_user_email) || @user.visible_custom_field_values.any? { _1.value.present? } end def visible_custom_fields diff --git a/app/models/permitted_params.rb b/app/models/permitted_params.rb index 944f962afaa..34d36be2cfc 100644 --- a/app/models/permitted_params.rb +++ b/app/models/permitted_params.rb @@ -263,7 +263,7 @@ class PermittedParams end def pref - params.fetch(:pref, {}).permit(:hide_mail, :time_zone, :theme, + params.fetch(:pref, {}).permit(:time_zone, :theme, :comments_sorting, :warn_on_leaving_unsaved, :auto_hide_popups) end diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index 220768c6a2d..041f930fe20 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -90,14 +90,6 @@ class UserPreference < ApplicationRecord settings.fetch(:diff_type, "inline") end - def hide_mail - settings.fetch(:hide_mail, true) - end - - def can_expose_mail? - !hide_mail - end - def auto_hide_popups=(value) settings[:auto_hide_popups] = to_boolean(value) end diff --git a/app/services/user_preferences/set_attributes_service.rb b/app/services/user_preferences/set_attributes_service.rb index ebbca864b57..61c32545e1d 100644 --- a/app/services/user_preferences/set_attributes_service.rb +++ b/app/services/user_preferences/set_attributes_service.rb @@ -29,8 +29,6 @@ module UserPreferences class SetAttributesService < ::BaseServices::SetAttributes def set_attributes(params) - set_boolean_value(:hide_mail, params.delete(:hide_mail)) if params.key?(:hide_mail) - params.each do |k, v| model[k] = v if model.supported_settings_method?(k) end diff --git a/app/views/common/feed.atom.builder b/app/views/common/feed.atom.builder index a95f90bd8c0..4a7aa3cd948 100644 --- a/app/views/common/feed.atom.builder +++ b/app/views/common/feed.atom.builder @@ -61,7 +61,9 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do if author xml.author do xml.name(author) - xml.email(author.mail) if author.is_a?(User) && author.mail.present? && author.pref.can_expose_mail? + if author.is_a?(User) && author.mail.present? && User.current.allowed_globally?(:view_user_email) + xml.email(author.mail) + end end end xml.content "type" => "html" do diff --git a/app/views/journals/index.atom.builder b/app/views/journals/index.atom.builder index 9723e810f9d..7a89fd16d88 100644 --- a/app/views/journals/index.atom.builder +++ b/app/views/journals/index.atom.builder @@ -44,7 +44,8 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do xml.updated change.created_at.xmlschema xml.author do xml.name change.user.name - xml.email(change.user.mail) if change.user.is_a?(User) && change.user.mail.present? && change.user.pref.can_expose_mail? + if change.user.is_a?(User) && change.user.mail.present? && User.current.allowed_globally?(:view_user_email) + xml.email(change.user.mail) end xml.content "type" => "html" do xml.text! "