FIX: use current_user.id in onebox instead of param

This commit is contained in:
Sam 2017-11-23 15:32:19 +11:00
parent 2fe131db9f
commit d43a54e83a
2 changed files with 4 additions and 5 deletions

View File

@ -48,7 +48,7 @@ function loadNext(ajax) {
// Retrieve the onebox // Retrieve the onebox
return ajax("/onebox", { return ajax("/onebox", {
dataType: 'html', dataType: 'html',
data: { url, refresh, user_id: userId }, data: { url, refresh },
cache: true cache: true
}).then(html => { }).then(html => {
let $html = $(html); let $html = $(html);

View File

@ -4,7 +4,6 @@ class OneboxController < ApplicationController
before_action :ensure_logged_in before_action :ensure_logged_in
def show def show
params.require(:user_id)
unless params[:refresh] == 'true' unless params[:refresh] == 'true'
preview = Oneboxer.cached_preview(params[:url]) preview = Oneboxer.cached_preview(params[:url])
@ -13,15 +12,15 @@ class OneboxController < ApplicationController
end end
# only 1 outgoing preview per user # only 1 outgoing preview per user
return render(body: nil, status: 429) if Oneboxer.is_previewing?(params[:user_id]) return render(body: nil, status: 429) if Oneboxer.is_previewing?(current_user.id)
Oneboxer.preview_onebox!(params[:user_id]) Oneboxer.preview_onebox!(current_user.id)
preview = Oneboxer.preview(params[:url], invalidate_oneboxes: params[:refresh] == 'true') preview = Oneboxer.preview(params[:url], invalidate_oneboxes: params[:refresh] == 'true')
preview.strip! if preview.present? preview.strip! if preview.present?
Scheduler::Defer.later("Onebox previewed") { Scheduler::Defer.later("Onebox previewed") {
Oneboxer.onebox_previewed!(params[:user_id]) Oneboxer.onebox_previewed!(current_user.id)
} }
if preview.blank? if preview.blank?