mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 23:06:19 +08: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
|
@ -19,9 +19,9 @@ module Oneboxer
|
|||
case route[:controller]
|
||||
when 'users'
|
||||
user = User.where(username_lower: route[:username].downcase).first
|
||||
return nil unless user
|
||||
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 New Issue
Block a user