Skip to content

Commit

Permalink
FIX: If a topic/post cannot be oneboxed, don't swallow the href.
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltrout committed Aug 24, 2013
1 parent 20e8a8a commit 2ce59d2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/oneboxer/discourse_local_onebox.rb
Expand Up @@ -28,12 +28,13 @@ def onebox

@template = 'user'
when 'topics'

linked = "<a href='#{@url}'>#{@url}</a>"
if route[:post_number].present? && route[:post_number].to_i > 1
# Post Link
post = Post.where(topic_id: route[:topic_id], post_number: route[:post_number].to_i).first
return nil unless post

return @url unless Guardian.new.can_see?(post)
return linked unless post
return linked unless Guardian.new.can_see?(post)

topic = post.topic
slug = Slug.for(topic.title)
Expand All @@ -50,9 +51,8 @@ def onebox
else
# Topic Link
topic = Topic.where(id: route[:topic_id].to_i).includes(:user).first
return nil unless topic

return @url unless Guardian.new.can_see?(topic)
return linked unless topic
return linked unless Guardian.new.can_see?(topic)

post = topic.posts.first

Expand Down

0 comments on commit 2ce59d2

Please sign in to comment.