Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

WIP - error_file_link also working

Frank Bergmannc8b56a7dc30c
diff --git a/modules/storages/lib/api/v3/file_links/work_packages_file_links_api.rb b/modules/storages/lib/api/v3/file_links/work_packages_file_links_api.rb
index efb7e554934..ffce201f7c1 100644
--- a/modules/storages/lib/api/v3/file_links/work_packages_file_links_api.rb
+++ b/modules/storages/lib/api/v3/file_links/work_packages_file_links_api.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)
diff --git a/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb b/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb
index f2cfa597588..07202f94881 100644
--- a/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb
+++ b/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb
@@ -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