mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: do not create topic link reflection for unlisted topics
This commit is contained in:
parent
29a9e0c4d2
commit
b00747fd49
@ -144,7 +144,6 @@ SQL
|
||||
url = "#{Discourse.base_url_no_prefix}#{topic.relative_url}"
|
||||
url << "/#{post_number}" if post_number.to_i > 1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Skip linking to ourselves
|
||||
@ -182,7 +181,7 @@ SQL
|
||||
if topic_id.present?
|
||||
topic = Topic.find_by(id: topic_id)
|
||||
|
||||
if topic && post.topic && post.topic.archetype != 'private_message' && topic.archetype != 'private_message'
|
||||
if topic && post.topic && topic.archetype != 'private_message' && post.topic.archetype != 'private_message' && post.topic.visible?
|
||||
prefix = Discourse.base_url_no_prefix
|
||||
reflected_url = "#{prefix}#{post.topic.relative_url(post.post_number)}"
|
||||
tl = TopicLink.find_by(topic_id: topic_id,
|
||||
|
@ -251,6 +251,21 @@ http://b.com/#{'a' * 500}
|
||||
|
||||
end
|
||||
|
||||
describe 'internal link from unlisted topic' do
|
||||
it 'works' do
|
||||
unlisted_topic = Fabricate(:topic, user: user, visible: false)
|
||||
url = "http://#{test_uri.host}/t/topic-slug/#{topic.id}"
|
||||
|
||||
unlisted_topic.posts.create(user: user, raw: 'initial post')
|
||||
linked_post = unlisted_topic.posts.create(user: user, raw: "Link to another topic: #{url}")
|
||||
|
||||
TopicLink.extract_from(linked_post)
|
||||
|
||||
expect(topic.topic_links.first).to eq(nil)
|
||||
expect(unlisted_topic.topic_links.first).not_to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'internal link with non-standard port' do
|
||||
it 'includes the non standard port if present' do
|
||||
other_topic = Fabricate(:topic, user: user)
|
||||
|
Loading…
Reference in New Issue
Block a user