FIX: external links in whisper ended up in a white page

FIX: clicking a link in a onebox wasn't properly extracting the post_id
This commit is contained in:
Régis Hanol
2017-12-20 17:55:15 +01:00
parent 6e1dd12390
commit 7f69362d9d
4 changed files with 40 additions and 27 deletions

View File

@@ -12,9 +12,14 @@ class ClicksController < ApplicationController
@redirect_url = TopicLinkClick.create_from(params)
end
# Sometimes we want to record a link without a 302. Since XHR has to load the redirected
# URL we want it to not return a 302 in those cases.
if params[:redirect] == 'false' || @redirect_url.blank?
# links in whispers aren't extracted, just allow the redirection to staff
if @redirect_url.blank? && current_user&.staff? && params[:post_id].present?
@redirect_url = params[:url] if Post.exists?(id: params[:post_id], post_type: Post.types[:whisper])
end
# Sometimes we want to record a link without a 302.
# Since XHR has to load the redirected URL we want it to not return a 302 in those cases.
if params[:redirect] == "false" || @redirect_url.blank?
render body: nil
else
redirect_to(@redirect_url)