Hide author name in anon discussions report notifications
closes VICE-2343 flag=react_discussions_post flag=discussion_anonymity flag=discussions_reporting test plan: - Specs pass - Go to an anonymous discussion. - Create an entry. - Report the entry. - Make sure the notification received has the anonymous author name. qa risk: low Change-Id: Id690b913639a087a0f663177d7f5c3ae1bf1f7a8 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/281050 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Chawn Neal <chawn.neal@instructure.com> QA-Review: Chawn Neal <chawn.neal@instructure.com> Product-Review: Chawn Neal <chawn.neal@instructure.com>
This commit is contained in:
parent
91e7e2fa0b
commit
5850e3c512
|
@ -6,7 +6,7 @@
|
||||||
<%= t :subject, "Reported reply in %{discussion_topic}, %{course}", discussion_topic: asset.discussion_topic.title, course: asset.context.name %>
|
<%= t :subject, "Reported reply in %{discussion_topic}, %{course}", discussion_topic: asset.discussion_topic.title, course: asset.context.name %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= t :body, "Reported as %{report_type}: %{user}, %{course}", report_type: data[:report_type], user: asset.user.short_name, course: asset.context.name %>
|
<%= t :body, "Reported as %{report_type}: %{user}, %{course}", report_type: data[:report_type], user: asset.author_name, course: asset.context.name %>
|
||||||
|
|
||||||
<%= html_to_text(asset.message, :base_url => dashboard_url) %>
|
<%= html_to_text(asset.message, :base_url => dashboard_url) %>
|
||||||
|
|
||||||
|
|
|
@ -17,20 +17,13 @@
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr >
|
<tr >
|
||||||
<td align="left" width="50" style="width: 50px"><img style="border-radius: 50px; height: 50px; width: 50px;" height="50" width="50" src="<%=author_avatar_url%>" alt="<%=author_short_name%>"> </td>
|
<td align="left" width="50" style="width: 50px"><img style="border-radius: 50px; height: 50px; width: 50px;" height="50" width="50" src="<%=author_avatar_url%>" alt="<%= asset.author_name %>"> </td>
|
||||||
<td width="10"></td>
|
<td width="10"></td>
|
||||||
<td>
|
<td>
|
||||||
<table border="0" style="font-size: 14px; color: #444444; background-color: #ffffff; font-family: 'Open Sans', 'Lucida Grande', 'Segoe UI', Arial, Verdana, 'Lucida Sans Unicode', Tahoma, 'Sans Serif';" valign="top" align="left">
|
<table border="0" style="font-size: 14px; color: #444444; background-color: #ffffff; font-family: 'Open Sans', 'Lucida Grande', 'Segoe UI', Arial, Verdana, 'Lucida Sans Unicode', Tahoma, 'Sans Serif';" valign="top" align="left">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="bottom" align="left">
|
<td valign="bottom" align="left">
|
||||||
<b><%= author_short_name%></b>
|
<b><%= asset.author_name %></b>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td valign="top" align="left">
|
|
||||||
<a href="mailto:<%= author_email_address %>">
|
|
||||||
<%= author_email_address%>
|
|
||||||
</a>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -40,15 +33,11 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<p height="30px"></p>
|
<p height="30px"></p>
|
||||||
<p>
|
<p>
|
||||||
<b><%= author_short_name%></b>
|
<b><%= asset.author_name %></b>
|
||||||
<br/>
|
|
||||||
<a href="mailto:<%= author_email_address %>">
|
|
||||||
<%= author_email_address%>
|
|
||||||
</a>
|
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= t :body, "Reported as %{report_type}: %{user}, %{course}", report_type: data[:report_type], user: asset.user.short_name, course: asset.context.name %>
|
<%= t :body, "Reported as %{report_type}: %{user}, %{course}", report_type: data[:report_type], user: asset.author_name, course: asset.context.name %>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= html_to_simple_html(asset.message, :base_url => dashboard_url) %>
|
<%= html_to_simple_html(asset.message, :base_url => dashboard_url) %>
|
||||||
|
|
|
@ -639,4 +639,20 @@ class DiscussionEntry < ActiveRecord::Base
|
||||||
def set_root_account_id
|
def set_root_account_id
|
||||||
self.root_account_id ||= discussion_topic.root_account_id
|
self.root_account_id ||= discussion_topic.root_account_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def author_name(current_user = nil)
|
||||||
|
current_user ||= self.current_user
|
||||||
|
|
||||||
|
if discussion_topic.anonymous?
|
||||||
|
discussion_topic_participant = DiscussionTopicParticipant.find_by(discussion_topic_id: discussion_topic_id, user_id: user.id)
|
||||||
|
|
||||||
|
if discussion_topic_participant.user == current_user
|
||||||
|
t("You")
|
||||||
|
else
|
||||||
|
t("Anonymous") + " " + discussion_topic_participant&.id.to_s(36)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
user.short_name
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,5 +40,13 @@ describe "reported_reply" do
|
||||||
expect(msg.body).to match(%r{/courses/\d+/discussion_topics/\d+})
|
expect(msg.body).to match(%r{/courses/\d+/discussion_topics/\d+})
|
||||||
expect(msg.html_body.include?("View the reply in the discussion: \n<a href=\"http://localhost/courses/#{@object.discussion_topic.course.id}/discussion_topics/#{@object.discussion_topic.id}?entry_id=#{@object.id}\">")).to eq(true)
|
expect(msg.html_body.include?("View the reply in the discussion: \n<a href=\"http://localhost/courses/#{@object.discussion_topic.course.id}/discussion_topics/#{@object.discussion_topic.id}?entry_id=#{@object.id}\">")).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "renders anonymous user if discussion is anonymous" do
|
||||||
|
@topic.anonymous_state = "fully_anonymous"
|
||||||
|
@topic.save!
|
||||||
|
|
||||||
|
msg = generate_message(notification_name, path_type, asset)
|
||||||
|
expect(msg.html_body.include?("Anonymous")).to eq(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
describe DiscussionEntry do
|
describe DiscussionEntry do
|
||||||
let(:topic) { discussion_topic_model }
|
let(:topic) { discussion_topic_model }
|
||||||
|
let(:anonymous_topic) { discussion_topic_model(anonymous_state: "fully_anonymous") }
|
||||||
|
|
||||||
describe "callback lifecycle" do
|
describe "callback lifecycle" do
|
||||||
before(:once) do
|
before(:once) do
|
||||||
|
@ -848,4 +849,22 @@ describe DiscussionEntry do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "author_name" do
|
||||||
|
let(:user) { user_model(name: "John Doe") }
|
||||||
|
let(:entry) { topic.discussion_entries.create!(message: "Hello!", user: user) }
|
||||||
|
let(:anon_entry) { anonymous_topic.discussion_entries.create!(message: "Hello!", user: user) }
|
||||||
|
|
||||||
|
it "returns author name" do
|
||||||
|
expect(entry.author_name).to eq "John Doe"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns anonymous author name" do
|
||||||
|
expect(anon_entry.author_name).to match(/Anonymous (.*)/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns You as anonymous author name" do
|
||||||
|
expect(anon_entry.author_name(user)).to eq "You"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue