WIP - error_file_link also working

pull/10868/head
Frank Bergmann 2 years ago
parent 7b18f59c7c
commit c8b56a7dc3
  1. 7
      modules/storages/lib/api/v3/file_links/work_packages_file_links_api.rb
  2. 2
      modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb

@ -50,6 +50,7 @@ module API
get do
# API supports query filters on storages:
# storage: { operator: '=', values: [storage_id]
# ToDo: Check if ParamsToQueryService raises condition?
query = ParamsToQueryService
.new(::Storages::Storage,
current_user,
@ -57,9 +58,10 @@ module API
.call(params)
unless query.valid?
message = I18n.t('api_v3.errors.missing_or_malformed_parameter', parameter: 'filters')
message = I18n.t('api_v3.errors.missing_or_malformed_parameter')
raise ::API::Errors::InvalidQuery.new(message)
end
# ToDo: Double-check that I've got this tested
# Get the list of all FileLinks for the work package.
# This could be a huge array in some cases...
@ -71,6 +73,7 @@ module API
begin
# Synchronize with Nextcloud. StorageAPI handles OAuth2 for us.
# We ignore the result, because partial errors (storage network issues) are written to each FileLink
service_result = ::Storages::FileLinkSyncService
.new(user: current_user)
.call(file_links)
@ -81,6 +84,8 @@ module API
current_user:
)
rescue StandardError => e
# ToDo: Check if API response handles exceptions like the one below (API.root)
# There was an error during the SyncService, which should normally not occur.
message = "#{I18n.t('api_v3.errors.code_500')}: #{e.message}"
raise ::API::Errors::InternalError.new(message)

@ -211,7 +211,7 @@ describe 'API v3 file links resource', with_flag: { storages_module_active: true
# The FileLink from a Nextcloud with timeout should have origin_permission=:error
error_file_link = elements.detect { |e| e["originData"]["id"] == "29" }
expect(other_user_file_link["_links"]["permission"]["href"]).to eql API::V3::FileLinks::URN_PERMISSION_ERROR
expect(error_file_link["_links"]["permission"]["href"]).to eql API::V3::FileLinks::URN_PERMISSION_ERROR
# ToDo: Search in elements for file_link with origin_id = '25' and check origin_permission = :not_authenticated
# ToDo: Search for '24' and check for perms = :view

Loading…
Cancel
Save