WIP - Added error message

pull/10868/head
Frank Bergmann 2 years ago
parent b6e83c8ec4
commit cfe668b9a7
  1. 16
      modules/storages/app/services/storages/file_link_sync_service.rb

@ -53,10 +53,20 @@ class Storages::FileLinkSyncService
oauth_client = OAuthClient.find_by(integration_id: storage_id)
connection_manager = ::OAuthClients::ConnectionManager.new(user: @user, oauth_client:)
service_result = connection_manager.get_access_token # No scope for Nextcloud...
oauth_client_token = service_result.result
# Return the error codes from ConnectionManager.get_access_token to calling method
return service_result unless service_result.success
# Return the errors from ConnectionManager.get_access_token to calling method
unless service_result.success do
# We should never get here, because the storages endpoint enforces OAuth auhorization
service_result.errors.add(
:base,
"User not authorized to access storage. \
Did you authorize OpenProject to connect to your storage with OAuth2?"
)
return service_result
end
oauth_client_token = service_result.result
# Get info about files. Result is either an Exception or Net::HTTPOK with body
storage_origin_file_ids = storage_file_links.map(&:origin_id)

Loading…
Cancel
Save