FIX: Use site contact user + group for Revise... review action (#29271)
Followup 9762e65758
When we added the Revise... option for posts/new topics
in the review queue, which sends a PM to the user, we used
`SystemMessage.create_from_system_user`, which always sends
the PM from the system user. However, this makes it so if the
user replies to the PM, which they are encouraged to do,
no one will see it unless they actively monitor the system inbox.
This commit changes it so `SystemMessage.create` is used,
which uses the `site_contact_username` and `site_contact_group`
site settings as participants in the sent PM. Then, when the
user replies, it will send to that inbox instead.
If `site_contact_username` is blank, the system user is used.
This commit is contained in:
parent
2db23fd871
commit
77f63a45d3
|
@ -173,7 +173,7 @@ class ReviewableQueuedPost < Reviewable
|
|||
original_post: self.payload["raw"],
|
||||
site_name: SiteSetting.title,
|
||||
}
|
||||
SystemMessage.create_from_system_user(
|
||||
SystemMessage.create(
|
||||
self.target_created_by,
|
||||
(
|
||||
if self.topic.blank?
|
||||
|
|
|
@ -126,6 +126,14 @@ RSpec.describe ReviewableQueuedPost, type: :model do
|
|||
end
|
||||
|
||||
context "with revise_and_reject_post" do
|
||||
fab!(:contact_group) { Fabricate(:group) }
|
||||
fab!(:contact_user) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
SiteSetting.site_contact_group_name = contact_group.name
|
||||
SiteSetting.site_contact_username = contact_user.username
|
||||
end
|
||||
|
||||
it "doesn't create the post the user intended" do
|
||||
post_count = Post.public_posts.count
|
||||
result = reviewable.perform(moderator, :revise_and_reject_post)
|
||||
|
@ -156,6 +164,8 @@ RSpec.describe ReviewableQueuedPost, type: :model do
|
|||
original_post: reviewable.payload["raw"],
|
||||
site_name: SiteSetting.title,
|
||||
}
|
||||
expect(topic.topic_allowed_users.pluck(:user_id)).to include(contact_user.id)
|
||||
expect(topic.topic_allowed_groups.pluck(:group_id)).to include(contact_group.id)
|
||||
expect(topic.first_post.raw.chomp).to eq(
|
||||
I18n.t(
|
||||
"system_messages.reviewable_queued_post_revise_and_reject.text_body_template",
|
||||
|
@ -175,6 +185,8 @@ RSpec.describe ReviewableQueuedPost, type: :model do
|
|||
}
|
||||
topic = Topic.where(archetype: Archetype.private_message).last
|
||||
|
||||
expect(topic.topic_allowed_users.pluck(:user_id)).to include(contact_user.id)
|
||||
expect(topic.topic_allowed_groups.pluck(:group_id)).to include(contact_group.id)
|
||||
expect(topic.first_post.raw).not_to include("Other...")
|
||||
expect(topic.first_post.raw).to include("Boring")
|
||||
end
|
||||
|
|
|
@ -130,6 +130,14 @@ describe "Reviewables", type: :system do
|
|||
end
|
||||
|
||||
context "when performing a review action from the show route" do
|
||||
fab!(:contact_group) { Fabricate(:group) }
|
||||
fab!(:contact_user) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
SiteSetting.site_contact_group_name = contact_group.name
|
||||
SiteSetting.site_contact_username = contact_user.username
|
||||
end
|
||||
|
||||
context "with a ReviewableQueuedPost" do
|
||||
fab!(:queued_post_reviewable) { Fabricate(:reviewable_queued_post) }
|
||||
|
||||
|
@ -170,7 +178,11 @@ describe "Reviewables", type: :system do
|
|||
|
||||
expect(review_page).to have_reviewable_with_rejected_status(queued_post_reviewable)
|
||||
expect(queued_post_reviewable.reload).to be_rejected
|
||||
expect(Topic.where(archetype: Archetype.private_message).last.title).to eq(
|
||||
|
||||
topic = Topic.where(archetype: Archetype.private_message).last
|
||||
expect(topic.topic_allowed_users.pluck(:user_id)).to include(contact_user.id)
|
||||
expect(topic.topic_allowed_groups.pluck(:group_id)).to include(contact_group.id)
|
||||
expect(topic.title).to eq(
|
||||
I18n.t(
|
||||
"system_messages.reviewable_queued_post_revise_and_reject.subject_template",
|
||||
topic_title: queued_post_reviewable.topic.title,
|
||||
|
|
Loading…
Reference in New Issue