mirror of
https://github.com/discourse/discourse.git
synced 2025-02-22 16:34:26 +08:00
BUGFIX: don't alery myself when I link to myself
This commit is contained in:
parent
5bc8e7c19b
commit
9fc31932cf
@ -143,11 +143,11 @@ class PostAlerter
|
|||||||
|
|
||||||
def extract_linked_users(post)
|
def extract_linked_users(post)
|
||||||
post.topic_links.map do |link|
|
post.topic_links.map do |link|
|
||||||
post = link.link_post
|
linked_post = link.link_post
|
||||||
if !post && topic = link.link_topic
|
if !linked_post && topic = link.link_topic
|
||||||
post = topic.posts(post_number: 1).first
|
linked_post = topic.posts(post_number: 1).first
|
||||||
end
|
end
|
||||||
post && post.user
|
linked_post && post.user_id != linked_post.user_id && linked_post.user
|
||||||
end.compact
|
end.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,10 +6,7 @@ describe PostAlerter do
|
|||||||
|
|
||||||
def create_post_with_alerts(args={})
|
def create_post_with_alerts(args={})
|
||||||
post = Fabricate(:post, args)
|
post = Fabricate(:post, args)
|
||||||
alerter = PostAlerter.new
|
PostAlerter.post_created(post)
|
||||||
alerter.after_create_post(post)
|
|
||||||
alerter.after_save_post(post)
|
|
||||||
post
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'quotes' do
|
context 'quotes' do
|
||||||
@ -35,6 +32,21 @@ describe PostAlerter do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'linked' do
|
||||||
|
it "will notify correctly on linking" do
|
||||||
|
post1 = create_post
|
||||||
|
user = post1.user
|
||||||
|
create_post(raw: "my magic topic\n##{Discourse.base_url}#{post1.url}")
|
||||||
|
|
||||||
|
user.notifications.count.should == 1
|
||||||
|
|
||||||
|
create_post(user: user, raw: "my magic topic\n##{Discourse.base_url}#{post1.url}")
|
||||||
|
|
||||||
|
user.reload
|
||||||
|
user.notifications.count.should == 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context '@mentions' do
|
context '@mentions' do
|
||||||
|
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user