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

[#47207] added location and permissions to storage file endpoint

Eric Schubert46351a46aa05
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_query.rb
index a0f7c44cd31..690ceee3eb0 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_query.rb
@@ -44,7 +44,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
def query(file_id)
file_info(file_id) >>
- method(:to_storage_file)
+ method(:storage_file)
end
private
@@ -82,7 +82,8 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
# rubocop:enable Metrics/AbcSize
- def to_storage_file(file_info_response)
+ # rubocop:disable Metrics/AbcSize
+ def storage_file(file_info_response)
data = file_info_response.ocs.data
storage_file = ::Storages::StorageFile.new(data.id,
data.name,
@@ -92,9 +93,21 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
Time.zone.at(data.mtime),
data.owner_name,
data.modifier_name,
- nil,
- nil)
+ location(data.path),
+ data.dav_permissions)
ServiceResult.success(result: storage_file)
end
+
+ # rubocop:enable Metrics/AbcSize
+
+ def location(files_path)
+ prefix = 'files/'
+ idx = files_path.rindex(prefix)
+ return '/' if idx == nil
+
+ idx += prefix.length - 1
+
+ files_path[idx..]
+ end
end
end