mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: auto-message shouldn't generate notifications
This commit is contained in:
parent
6cd4330335
commit
c8631a7a8b
@ -187,7 +187,7 @@ class PostAction < ActiveRecord::Base
|
|||||||
return if moderator_already_replied?(related_post.topic, moderator)
|
return if moderator_already_replied?(related_post.topic, moderator)
|
||||||
message_key = "flags_dispositions.#{disposition}"
|
message_key = "flags_dispositions.#{disposition}"
|
||||||
message_key << "_and_deleted" if delete_post
|
message_key << "_and_deleted" if delete_post
|
||||||
related_post.topic.add_moderator_post(moderator, I18n.t(message_key))
|
related_post.topic.add_moderator_post(moderator, I18n.t(message_key), skip_notifications: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def moderator_already_replied?(topic, moderator)
|
def moderator_already_replied?(topic, moderator)
|
||||||
|
@ -488,6 +488,7 @@ class Topic < ActiveRecord::Base
|
|||||||
raw: text,
|
raw: text,
|
||||||
post_type: Post.types[:moderator_action],
|
post_type: Post.types[:moderator_action],
|
||||||
no_bump: opts[:bump].blank?,
|
no_bump: opts[:bump].blank?,
|
||||||
|
skip_notifications: opts[:skip_notifications],
|
||||||
topic_id: self.id)
|
topic_id: self.id)
|
||||||
new_post = creator.create
|
new_post = creator.create
|
||||||
increment!(:moderator_posts_count)
|
increment!(:moderator_posts_count)
|
||||||
|
@ -96,7 +96,7 @@ class PostCreator
|
|||||||
|
|
||||||
if @post && @post.errors.empty?
|
if @post && @post.errors.empty?
|
||||||
publish
|
publish
|
||||||
PostAlerter.post_created(@post) unless @opts[:import_mode]
|
PostAlerter.post_created(@post) unless @opts[:import_mode] || @opts[:skip_notifications]
|
||||||
|
|
||||||
track_latest_on_category
|
track_latest_on_category
|
||||||
enqueue_jobs
|
enqueue_jobs
|
||||||
|
@ -28,7 +28,7 @@ describe PostAction do
|
|||||||
mod = moderator
|
mod = moderator
|
||||||
Group.refresh_automatic_groups!
|
Group.refresh_automatic_groups!
|
||||||
|
|
||||||
action = PostAction.act(codinghorror, post, PostActionType.types[:notify_moderators], message: "this is my special long message");
|
action = PostAction.act(codinghorror, post, PostActionType.types[:notify_moderators], message: "this is my special long message")
|
||||||
|
|
||||||
posts = Post.joins(:topic)
|
posts = Post.joins(:topic)
|
||||||
.select('posts.id, topics.subtype, posts.topic_id')
|
.select('posts.id, topics.subtype, posts.topic_id')
|
||||||
@ -76,7 +76,7 @@ describe PostAction do
|
|||||||
it "creates a pm if selected" do
|
it "creates a pm if selected" do
|
||||||
post = build(:post, id: 1000)
|
post = build(:post, id: 1000)
|
||||||
PostCreator.any_instance.expects(:create).returns(post)
|
PostCreator.any_instance.expects(:create).returns(post)
|
||||||
PostAction.act(build(:user), build(:post), PostActionType.types[:notify_moderators], message: "this is my special message");
|
PostAction.act(build(:user), build(:post), PostActionType.types[:notify_moderators], message: "this is my special message")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ describe PostAction do
|
|||||||
|
|
||||||
it "sends an email to user if selected" do
|
it "sends an email to user if selected" do
|
||||||
PostCreator.any_instance.expects(:create).returns(build(:post))
|
PostCreator.any_instance.expects(:create).returns(build(:post))
|
||||||
PostAction.act(build(:user), post, PostActionType.types[:notify_user], message: "this is my special message");
|
PostAction.act(build(:user), post, PostActionType.types[:notify_user], message: "this is my special message")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -458,4 +458,18 @@ describe PostAction do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe ".add_moderator_post_if_needed" do
|
||||||
|
|
||||||
|
it "should not generate a notification for auto-message" do
|
||||||
|
post = create_post
|
||||||
|
|
||||||
|
PostAction.act(moderator, post, PostActionType.types[:spam], message: "WAT")
|
||||||
|
|
||||||
|
PostAlerter.expects(:post_created).never
|
||||||
|
|
||||||
|
PostAction.agree_flags!(post, admin)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user