mirror of
https://github.com/discourse/discourse.git
synced 2025-06-10 18:03:44 +08:00
FIX: If a topic/post cannot be oneboxed, don't swallow the href.
This commit is contained in:
@ -28,12 +28,13 @@ module Oneboxer
|
|||||||
|
|
||||||
@template = 'user'
|
@template = 'user'
|
||||||
when 'topics'
|
when 'topics'
|
||||||
|
|
||||||
|
linked = "<a href='#{@url}'>#{@url}</a>"
|
||||||
if route[:post_number].present? && route[:post_number].to_i > 1
|
if route[:post_number].present? && route[:post_number].to_i > 1
|
||||||
# Post Link
|
# Post Link
|
||||||
post = Post.where(topic_id: route[:topic_id], post_number: route[:post_number].to_i).first
|
post = Post.where(topic_id: route[:topic_id], post_number: route[:post_number].to_i).first
|
||||||
return nil unless post
|
return linked unless post
|
||||||
|
return linked unless Guardian.new.can_see?(post)
|
||||||
return @url unless Guardian.new.can_see?(post)
|
|
||||||
|
|
||||||
topic = post.topic
|
topic = post.topic
|
||||||
slug = Slug.for(topic.title)
|
slug = Slug.for(topic.title)
|
||||||
@ -50,9 +51,8 @@ module Oneboxer
|
|||||||
else
|
else
|
||||||
# Topic Link
|
# Topic Link
|
||||||
topic = Topic.where(id: route[:topic_id].to_i).includes(:user).first
|
topic = Topic.where(id: route[:topic_id].to_i).includes(:user).first
|
||||||
return nil unless topic
|
return linked unless topic
|
||||||
|
return linked unless Guardian.new.can_see?(topic)
|
||||||
return @url unless Guardian.new.can_see?(topic)
|
|
||||||
|
|
||||||
post = topic.posts.first
|
post = topic.posts.first
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user