mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: If you don't have permission to onebox a post, just show the link instead of crashing out
This commit is contained in:
parent
e8f3e7c2e8
commit
e83cd9d111
1 changed files with 5 additions and 4 deletions
|
@ -21,7 +21,7 @@ module Oneboxer
|
|||
user = User.where(username_lower: route[:username].downcase).first
|
||||
return nil unless user
|
||||
|
||||
Guardian.new.ensure_can_see!(user)
|
||||
return @url unless Guardian.new.can_see?(user)
|
||||
|
||||
args.merge! avatar: PrettyText.avatar_img(user.username, 'tiny'), username: user.username
|
||||
args[:bio] = user.bio_cooked if user.bio_cooked.present?
|
||||
|
@ -33,7 +33,7 @@ module Oneboxer
|
|||
post = Post.where(topic_id: route[:topic_id], post_number: route[:post_number].to_i).first
|
||||
return nil unless post
|
||||
|
||||
Guardian.new.ensure_can_see!(post)
|
||||
return @url unless Guardian.new.can_see?(post)
|
||||
|
||||
topic = post.topic
|
||||
slug = Slug.for(topic.title)
|
||||
|
@ -52,7 +52,8 @@ module Oneboxer
|
|||
topic = Topic.where(id: route[:topic_id].to_i).includes(:user).first
|
||||
return nil unless topic
|
||||
|
||||
Guardian.new.ensure_can_see!(topic)
|
||||
return @url unless Guardian.new.can_see?(topic)
|
||||
|
||||
post = topic.posts.first
|
||||
|
||||
posters = topic.posters_summary.map do |p|
|
||||
|
|
Loading…
Reference in a new issue