From e4c5c66d352a9f6b7b8533dbe83f75606abd4d8a Mon Sep 17 00:00:00 2001 From: ajugo Date: Thu, 21 Jul 2022 14:19:06 +0200 Subject: [PATCH] Fix wopi file creation [SCI-7014] (#4276) --- app/controllers/assets_controller.rb | 3 +-- app/serializers/asset_serializer.rb | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index ba458335d..a2a3f374a 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -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 diff --git a/app/serializers/asset_serializer.rb b/app/serializers/asset_serializer.rb index 75b71d771..ce891706f 100644 --- a/app/serializers/asset_serializer.rb +++ b/app/serializers/asset_serializer.rb @@ -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?