mirror of
https://github.com/discourse/discourse.git
synced 2025-03-03 01:39:19 +00:00
FIX: if prioritizing names in ux choose name over username in email
This commit is contained in:
parent
3ed2d645a3
commit
115c454002
app
spec/mailers
@ -58,7 +58,18 @@ module UserNotificationsHelper
|
|||||||
name.downcase.gsub(/[\s_-]/, '')
|
name.downcase.gsub(/[\s_-]/, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show_username_on_post(post)
|
||||||
|
return true if SiteSetting.prioritize_username_in_ux
|
||||||
|
return true unless SiteSetting.enable_names?
|
||||||
|
return true unless SiteSetting.display_name_on_posts?
|
||||||
|
return true unless post.user.name.present?
|
||||||
|
|
||||||
|
normalize_name(post.user.name) != normalize_name(post.user.username)
|
||||||
|
end
|
||||||
|
|
||||||
def show_name_on_post(post)
|
def show_name_on_post(post)
|
||||||
|
return true unless SiteSetting.prioritize_username_in_ux
|
||||||
|
|
||||||
SiteSetting.enable_names? &&
|
SiteSetting.enable_names? &&
|
||||||
SiteSetting.display_name_on_posts? &&
|
SiteSetting.display_name_on_posts? &&
|
||||||
post.user.name.present? &&
|
post.user.name.present? &&
|
||||||
|
@ -8,7 +8,9 @@
|
|||||||
<img src="<%= post.user.small_avatar_url %>" title="<%= post.user.username%>">
|
<img src="<%= post.user.small_avatar_url %>" title="<%= post.user.username%>">
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
<%- if show_username_on_post(post) %>
|
||||||
<a class="username" href="<%=Discourse.base_url%>/users/<%= post.user.username_lower%>" target="_blank"><%= post.user.username %></a>
|
<a class="username" href="<%=Discourse.base_url%>/users/<%= post.user.username_lower%>" target="_blank"><%= post.user.username %></a>
|
||||||
|
<% end %>
|
||||||
<%- if show_name_on_post(post) %>
|
<%- if show_name_on_post(post) %>
|
||||||
<a class="user-name" href="<%=Discourse.base_url%>/users/<%= post.user.username_lower%>" target="_blank"><%= post.user.name %></a>
|
<a class="user-name" href="<%=Discourse.base_url%>/users/<%= post.user.username_lower%>" target="_blank"><%= post.user.name %></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -232,6 +232,39 @@ describe UserNotifications do
|
|||||||
|
|
||||||
|
|
||||||
expect(mail.html_part.to_s.scan(/In Reply To/).count).to eq(0)
|
expect(mail.html_part.to_s.scan(/In Reply To/).count).to eq(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SiteSetting.enable_names = true
|
||||||
|
SiteSetting.display_name_on_posts = true
|
||||||
|
SiteSetting.prioritize_username_in_ux = false
|
||||||
|
|
||||||
|
response.user.username = "bobmarley"
|
||||||
|
response.user.name = "Bob Marley"
|
||||||
|
response.user.save
|
||||||
|
|
||||||
|
mail = UserNotifications.user_replied(response.user,
|
||||||
|
post: response,
|
||||||
|
notification_type: notification.notification_type,
|
||||||
|
notification_data_hash: notification.data_hash
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
mail_html = mail.html_part.to_s
|
||||||
|
expect(mail_html.scan(/>Bob Marley/).count).to eq(1)
|
||||||
|
expect(mail_html.scan(/>bobmarley/).count).to eq(0)
|
||||||
|
|
||||||
|
SiteSetting.prioritize_username_in_ux = true
|
||||||
|
|
||||||
|
mail = UserNotifications.user_replied(response.user,
|
||||||
|
post: response,
|
||||||
|
notification_type: notification.notification_type,
|
||||||
|
notification_data_hash: notification.data_hash
|
||||||
|
)
|
||||||
|
|
||||||
|
mail_html = mail.html_part.to_s
|
||||||
|
expect(mail_html.scan(/>Bob Marley/).count).to eq(0)
|
||||||
|
expect(mail_html.scan(/>bobmarley/).count).to eq(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user