FIX: If forcing a refresh, don't return a onebox preview

This commit is contained in:
Robin Ward 2017-06-12 13:59:42 -04:00
parent 0b41046238
commit 2ff850d446
1 changed files with 5 additions and 4 deletions

View File

@ -6,10 +6,11 @@ class OneboxController < ApplicationController
def show
params.require(:user_id)
preview = Oneboxer.cached_preview(params[:url])
preview.strip! if preview.present?
return render(plain: preview) if preview.present?
unless params[:refresh] == 'true'
preview = Oneboxer.cached_preview(params[:url])
preview.strip! if preview.present?
return render(plain: preview) if preview.present?
end
# only 1 outgoing preview per user
return render(nothing: true, status: 429) if Oneboxer.is_previewing?(params[:user_id])