Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

refactoring: use positive conditions

Christophe Bliarde9eed2cdd388
diff --git a/app/views/common/feed.atom.builder b/app/views/common/feed.atom.builder
index 84a6383a020..c243b0bdc87 100644
--- a/app/views/common/feed.atom.builder
+++ b/app/views/common/feed.atom.builder
@@ -60,7 +60,7 @@ 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.hide_mail
+ xml.email(author.mail) if author.is_a?(User) && author.mail.present? && author.pref.can_expose_mail?
end
end
xml.content "type" => "html" do
diff --git a/app/views/journals/index.atom.builder b/app/views/journals/index.atom.builder
index c96f4d7c387..3f873ddc27e 100644
--- a/app/views/journals/index.atom.builder
+++ b/app/views/journals/index.atom.builder
@@ -44,7 +44,7 @@ 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.hide_mail
+ xml.email(change.user.mail) if change.user.is_a?(User) && change.user.mail.present? && change.user.pref.can_expose_mail?
end
xml.content "type" => "html" do
xml.text! '<ul>'
diff --git a/lib/api/v3/users/user_representer.rb b/lib/api/v3/users/user_representer.rb
index d74d4d5df41..dab1227ae64 100644
--- a/lib/api/v3/users/user_representer.rb
+++ b/lib/api/v3/users/user_representer.rb
@@ -143,7 +143,7 @@ module API
getter: ->(*) { represented.mail },
setter: ->(fragment:, represented:, **) { represented.mail = fragment },
exec_context: :decorator,
- cache_if: -> { !represented.pref.hide_mail || represented.new_record? || current_user_can_manage? }
+ cache_if: -> { represented.pref.can_expose_mail? || represented.new_record? || current_user_can_manage? }
property :avatar,
exec_context: :decorator,