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

Factored out a helper method in StorageRepresenter

Andreas Pfohl70d9b33c2152
diff --git a/modules/storages/lib/api/v3/storages/storage_representer.rb b/modules/storages/lib/api/v3/storages/storage_representer.rb
index 111b8608868..b4f78a6815f 100644
--- a/modules/storages/lib/api/v3/storages/storage_representer.rb
+++ b/modules/storages/lib/api/v3/storages/storage_representer.rb
@@ -178,14 +178,14 @@ module API::V3::Storages
end
associated_resource :oauth_application,
- skip_render: ->(*) { !current_user.admin? || !represented.provider_type_nextcloud? },
+ skip_render: ->(*) { !represent_oauth_application? },
getter: ->(*) {
- next unless current_user.admin? && represented.provider_type_nextcloud?
+ next unless represent_oauth_application?
::API::V3::OAuth::OAuthApplicationsRepresenter.create(represented.oauth_application, current_user:)
},
link: ->(*) {
- next unless current_user.admin? && represented.provider_type_nextcloud?
+ next unless represent_oauth_application?
{
href: api_v3_paths.oauth_application(represented.oauth_application.id),
@@ -211,6 +211,10 @@ module API::V3::Storages
private
+ def represent_oauth_application?
+ current_user.admin? && represented.provider_type_nextcloud?
+ end
+
def storage_projects(storage)
storage.projects.merge(Project.allowed_to(current_user, :manage_file_links))
end