Fix wopi file creation [SCI-7014] (#4276)

This commit is contained in:
ajugo 2022-07-21 14:19:06 +02:00 committed by GitHub
parent b9d953b3a4
commit e4c5c66d35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -202,10 +202,9 @@ class AssetsController < ApplicationController
# Prepare file preview in advance
asset.medium_preview.processed && asset.large_preview.processed
# Return edit url and asset info
render json: {
attributes: AssetSerializer.new(asset, user: current_user).as_json,
attributes: AssetSerializer.new(asset, scope: { user: current_user }).as_json,
success: true,
edit_url: edit_url
}, status: :ok

View file

@ -93,6 +93,7 @@ class AssetSerializer < ActiveModel::Serializer
end
def urls
@user = scope[:user] || @instance_options[:user]
urls = {
preview: asset_file_preview_path(object),
download: rails_blob_path(object.file, disposition: 'attachment'),
@ -101,7 +102,7 @@ class AssetSerializer < ActiveModel::Serializer
marvin_js: marvin_js_asset_path(object),
marvin_js_icon: image_path('icon_small/marvinjs.svg')
}
if can_manage_asset?(object)
if can_manage_asset?(@user, object)
urls.merge!(
toggle_view_mode: toggle_view_mode_path(object),
edit_asset: edit_asset_path(object),
@ -110,7 +111,7 @@ class AssetSerializer < ActiveModel::Serializer
delete: asset_destroy_path(object)
)
end
if wopi && can_manage_asset?(object)
if wopi && can_manage_asset?(@user, object)
urls[:wopi_action] = object.get_action_url(@instance_options[:user], 'embedview')
end
urls[:blob] = rails_blob_path(object.file, disposition: 'attachment') if object.file.attached?