mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
FEATURE: when a post is deleted because a moderator agreed with flags, send a message to the post author
This commit is contained in:
parent
e4480ad0d2
commit
fe39cdc90a
@ -2241,6 +2241,20 @@ en:
|
|||||||
|
|
||||||
For additional guidance, please refer to our [community guidelines](%{base_url}/guidelines).
|
For additional guidance, please refer to our [community guidelines](%{base_url}/guidelines).
|
||||||
|
|
||||||
|
flags_agreed_and_post_deleted:
|
||||||
|
title: "Post deleted by a moderator"
|
||||||
|
subject_template: "Post deleted by a moderator due to flags"
|
||||||
|
text_body_template: |
|
||||||
|
Hello,
|
||||||
|
|
||||||
|
This is an automated message from %{site_name} to let you know that your post was deleted.
|
||||||
|
|
||||||
|
<%{base_url}%{url}>
|
||||||
|
|
||||||
|
A moderator reviewed flags submitted by the community and agreed with them.
|
||||||
|
|
||||||
|
Please review our [community guidelines](%{base_url}/guidelines) to avoid this happening again in the future.
|
||||||
|
|
||||||
usage_tips:
|
usage_tips:
|
||||||
text_body_template: |
|
text_body_template: |
|
||||||
For a few quick tips on getting started as a new user, [check out this blog post](https://blog.discourse.org/2016/12/discourse-new-user-tips-and-tricks/).
|
For a few quick tips on getting started as a new user, [check out this blog post](https://blog.discourse.org/2016/12/discourse-new-user-tips-and-tricks/).
|
||||||
|
@ -196,6 +196,15 @@ class PostDestroyer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def agree_with_flags
|
def agree_with_flags
|
||||||
|
if @post.is_flagged?
|
||||||
|
Jobs.enqueue(
|
||||||
|
:send_system_message,
|
||||||
|
user_id: @post.user.id,
|
||||||
|
message_type: :flags_agreed_and_post_deleted,
|
||||||
|
message_options: { url: @post.url }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
PostAction.agree_flags!(@post, @user, delete_post: true)
|
PostAction.agree_flags!(@post, @user, delete_post: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -567,6 +567,8 @@ describe PostDestroyer do
|
|||||||
let!(:flag) { PostAction.act(moderator, second_post, PostActionType.types[:off_topic]) }
|
let!(:flag) { PostAction.act(moderator, second_post, PostActionType.types[:off_topic]) }
|
||||||
|
|
||||||
it "should delete public post actions and agree with flags" do
|
it "should delete public post actions and agree with flags" do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
|
||||||
second_post.expects(:update_flagged_posts_count)
|
second_post.expects(:update_flagged_posts_count)
|
||||||
|
|
||||||
PostDestroyer.new(moderator, second_post).destroy
|
PostDestroyer.new(moderator, second_post).destroy
|
||||||
@ -580,6 +582,10 @@ describe PostDestroyer do
|
|||||||
second_post.reload
|
second_post.reload
|
||||||
expect(second_post.bookmark_count).to eq(0)
|
expect(second_post.bookmark_count).to eq(0)
|
||||||
expect(second_post.off_topic_count).to eq(1)
|
expect(second_post.off_topic_count).to eq(1)
|
||||||
|
|
||||||
|
notification = second_post.user.notifications.where(notification_type: Notification.types[:private_message]).last
|
||||||
|
expect(notification).to be_present
|
||||||
|
expect(notification.topic.title).to eq(I18n.t('system_messages.flags_agreed_and_post_deleted.subject_template'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -233,6 +233,19 @@ describe PostAction do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "undo/redo repeatedly" do
|
||||||
|
it "doesn't create a second action for the same user/type" do
|
||||||
|
PostAction.act(codinghorror, post, PostActionType.types[:like])
|
||||||
|
PostAction.remove_act(codinghorror, post, PostActionType.types[:like])
|
||||||
|
PostAction.act(codinghorror, post, PostActionType.types[:like])
|
||||||
|
expect(PostAction.where(post: post).with_deleted.count).to eq(1)
|
||||||
|
PostAction.remove_act(codinghorror, post, PostActionType.types[:like])
|
||||||
|
|
||||||
|
# Check that we don't lose consistency into negatives
|
||||||
|
expect(post.reload.like_count).to eq(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'when a user likes something' do
|
describe 'when a user likes something' do
|
||||||
|
|
||||||
it 'should generate notifications correctly' do
|
it 'should generate notifications correctly' do
|
||||||
@ -307,22 +320,7 @@ describe PostAction do
|
|||||||
expect(actual_count).to eq(1), "Expected likes_given to be 1 when removing '#{type_name}', but got #{actual_count}"
|
expect(actual_count).to eq(1), "Expected likes_given to be 1 when removing '#{type_name}', but got #{actual_count}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
describe "undo/redo repeatedly" do
|
|
||||||
it "doesn't create a second action for the same user/type" do
|
|
||||||
PostAction.act(codinghorror, post, PostActionType.types[:like])
|
|
||||||
PostAction.remove_act(codinghorror, post, PostActionType.types[:like])
|
|
||||||
PostAction.act(codinghorror, post, PostActionType.types[:like])
|
|
||||||
expect(PostAction.where(post: post).with_deleted.count).to eq(1)
|
|
||||||
PostAction.remove_act(codinghorror, post, PostActionType.types[:like])
|
|
||||||
|
|
||||||
# Check that we don't lose consistency into negatives
|
|
||||||
expect(post.reload.like_count).to eq(0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'when a user likes something' do
|
|
||||||
it 'should increase the like counts when a user votes' do
|
it 'should increase the like counts when a user votes' do
|
||||||
expect {
|
expect {
|
||||||
PostAction.act(codinghorror, post, PostActionType.types[:like])
|
PostAction.act(codinghorror, post, PostActionType.types[:like])
|
||||||
|
Loading…
Reference in New Issue
Block a user