Skip to content

Commit

Permalink
Fix reply searcher error (#2414)
Browse files Browse the repository at this point in the history
Checking if the post is invisible should happen *before* trying to set up instance variables
  • Loading branch information
teceler authored Feb 1, 2025
1 parent e28789d commit 79fc35f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/controllers/replies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ def search
@post = Post.find_by(id: params[:post_id]) if params[:post_id].present?
@icon = Icon.find_by(id: params[:icon_id]) if params[:icon_id].present?

searcher = Reply::Searcher.new(current_user: current_user, post: @post)
searcher.setup(params)

@users = searcher.users
@characters = searcher.characters
@templates = searcher.templates
@boards = searcher.boards

if @post&.visible_to?(current_user)
gon.post_id = @post.id
elsif @post
Expand All @@ -32,6 +24,14 @@ def search
return
end

searcher = Reply::Searcher.new(current_user: current_user, post: @post)
searcher.setup(params)

@users = searcher.users
@characters = searcher.characters
@templates = searcher.templates
@boards = searcher.boards

return unless params[:commit].present?

response.headers['X-Robots-Tag'] = 'noindex'
Expand Down

0 comments on commit 79fc35f

Please sign in to comment.