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

Merge branch 'release/13.2' into dev

Eric Schubertdfb29e4056d5
diff --cc modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb
index 462d1c24c5d,e19a892ea64..c1380290898
--- a/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb
+++ b/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb
@@@ -47,10 -48,10 +47,10 @@@ module Storage
util = ::Storages::Peripherals::StorageInteraction::OneDrive::Util
authorization_check_wrapper do
- HTTPX.get(
+ OpenProject.httpx.get(
util.join_uri_path(@uri, '/v1.0/me'),
headers: { 'Authorization' => "Bearer #{access_token}", 'Accept' => 'application/json' }
- ).status
+ )
end
end
diff --cc modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb
index 3f657a54a0e,b87c9510a39..ba10f42b97d
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/download_link_query.rb
@@@ -84,10 -58,33 +58,33 @@@ module Storages::Peripherals::StorageIn
.map { |download_token| download_link(download_token, file_link.origin_name) }
end
- # rubocop:enable Metrics/AbcSize
-
private
+ def direct_download_request(token, file_link)
- response = Util
++ response = OpenProject
+ .httpx
+ .post(
+ Util.join_uri_path(@uri, '/ocs/v2.php/apps/dav/api/v1/direct'),
+ json: { fileId: file_link.origin_id },
+ headers: {
+ 'Authorization' => "Bearer #{token.access_token}",
+ 'OCS-APIRequest' => 'true',
+ 'Accept' => 'application/json',
+ 'Content-Type' => 'application/json'
+ }
+ )
+ case response
+ in { status: 200..299 }
+ ServiceResult.success(result: response)
+ in { status: 404 }
+ Util.error(:not_found, 'Outbound request destination not found!', response)
+ in { status: 401 }
+ Util.error(:unauthorized, 'Outbound request not authorized!', response)
+ else
+ Util.error(:error, 'Outbound request failed!')
+ end
+ end
+
def download_link(token, origin_name)
Util.join_uri_path(@uri, 'index.php/apps/integration_openproject/direct', token, CGI.escape(origin_name))
end
diff --cc modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb
index e4556e87e39,622f07217db..0cf4f57d18a
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb
@@@ -44,10 -44,10 +44,10 @@@ module Storages::Peripherals::StorageIn
# rubocop:disable Metrics/AbcSize
def call(group:)
- response = Util
+ response = OpenProject
.httpx
.basic_auth(@username, @password)
- .with(headers: {'OCS-APIRequest' => 'true'})
+ .with(headers: { 'OCS-APIRequest' => 'true' })
.get(Util.join_uri_path(@uri, "ocs/v1.php/cloud/groups", CGI.escapeURIComponent(group)))
error_data = Storages::StorageErrorData.new(source: self.class, payload: response)
diff --cc modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query.rb
index 3c64fbd2c61,bf5199761a9..05d7585c367
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query.rb
@@@ -90,10 -90,10 +90,10 @@@ module Storages::Peripherals::StorageIn
end
end.to_xml
- response = UTIL
+ response = OpenProject
.httpx
.basic_auth(@username, @password)
- .with(headers: { "Depth" => depth})
+ .with(headers: { "Depth" => depth })
.request(
"PROPFIND",
UTIL.join_uri_path(
diff --cc modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb
index 7b6e6aea72d,3d789cac958..3bd35834a48
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb
@@@ -65,8 -64,8 +64,8 @@@ module Storages::Peripherals::StorageIn
private
- def outbound_response(method:, relative_path:, payload:, token:)
+ def outbound_response(relative_path:, payload:, token:)
- response = Util
+ response = OpenProject
.httpx
.with(headers: { 'Authorization' => "Bearer #{token.access_token}",
'Accept' => 'application/json',
diff --cc modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb
index 1c778689343,44225327b60..4c544ba3b71
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb
@@@ -65,21 -65,16 +65,21 @@@ module Storage
end
def handle_response(response)
- error_data = ::Storages::StorageErrorData.new(source: self, payload: response.body)
++ data = ::Storages::StorageErrorData.new(source: self.class, payload: response)
+
- case response.status
- when 200..299
- upload_url = MultiJson.load(response.body, symbolize_keys: true)[:uploadUrl]
+ case response
+ in { status: 200..299 }
- upload_url = MultiJson.load(response.body, symbolize_keys: true)[:uploadUrl]
++ upload_url = response.json(symbolize_keys: true)[:uploadUrl]
ServiceResult.success(result: ::Storages::UploadLink.new(URI(upload_url), :put))
- when 404
+ in { status: 404 }
- ServiceResult.failure(result: :not_found, errors: ::Storages::StorageError.new(code: :not_found))
+ ServiceResult.failure(result: :not_found,
- errors: ::Storages::StorageError.new(code: :not_found, data: error_data))
- when 401
++ errors: ::Storages::StorageError.new(code: :not_found, data: ))
+ in { status: 401 }
- ServiceResult.failure(result: :unauthorized, errors: ::Storages::StorageError.new(code: :unauthorized))
+ ServiceResult.failure(result: :unauthorized,
- errors: ::Storages::StorageError.new(code: :unauthorized, data: error_data))
++ errors: ::Storages::StorageError.new(code: :unauthorized, data:))
else
- ServiceResult.failure(result: :error, errors: ::Storages::StorageError.new(code: :error))
+ ServiceResult.failure(result: :error,
- errors: ::Storages::StorageError.new(code: :error, data: error_data))
++ errors: ::Storages::StorageError.new(code: :error, data: ))
end
end