FIX: Show the envelope icon when the flagged post is a PM. Flagged PM must be exclusively reviewed by admins (#9232)

This commit is contained in:
Roman Rizzi 2020-03-19 15:12:42 -03:00 committed by GitHub
parent 226d81fcc5
commit 080960a15e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,6 @@
<div class='post-topic'>
{{#if reviewable.topic}}
{{topic-status topic=reviewable.topic}}
{{topic-status topic=reviewable.topic showPrivateMessageIcon=true}}
<a href={{reviewable.target_url}} class='title-text'>{{reviewable.topic.title}}</a>
{{category-badge reviewable.category}}
{{reviewable-tags tags=reviewable.topic_tags tagName=''}}

View File

@ -133,7 +133,7 @@ class Reviewable < ActiveRecord::Base
target: target,
topic: topic,
created_by: created_by,
reviewable_by_moderator: reviewable_by_moderator,
reviewable_by_moderator: reviewable_by_moderator && !(topic&.private_message?),
payload: payload,
potential_spam: potential_spam
)

View File

@ -78,6 +78,17 @@ RSpec.describe Reviewable, type: :model do
expect(r1.pending?).to eq(true)
expect(r0.pending?).to eq(false)
end
it 'sets the reviewable_by_moderator attribute to false when the topic is a PM' do
pm_topic = Fabricate(:private_message_topic)
post = Fabricate(:post, topic: pm_topic)
reviewable = ReviewableFlaggedPost.needs_review!(
target: post, topic: pm_topic,
created_by: Discourse.system_user, reviewable_by_moderator: true
)
expect(reviewable.reviewable_by_moderator).to eq(false)
end
end
context ".list_for" do