FIX: include title in local onebox when linking to a different topic

This commit is contained in:
Régis Hanol
2018-02-19 22:40:14 +01:00
parent 614b1c8e68
commit 60ec483caa
6 changed files with 41 additions and 19 deletions

View File

@@ -170,6 +170,10 @@ module Oneboxer
return unless Guardian.new(current_user).can_see_category?(current_category)
end
if current_topic = Topic.find_by(id: opts[:topic_id])
return unless Guardian.new(current_user).can_see_topic?(current_topic)
end
topic = Topic.find_by(id: route[:topic_id])
return unless topic
@@ -187,7 +191,7 @@ module Oneboxer
return if !post || post.hidden || post.post_type != Post.types[:regular]
if post_number > 1
if post_number > 1 && current_topic&.id == topic.id
excerpt = post.excerpt(SiteSetting.post_onebox_maxlength)
excerpt.gsub!(/[\r\n]+/, " ")
excerpt.gsub!("[/quote]", "[quote]") # don't break my quote