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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Cleanup mostly done.
Marcello Rocha5a5bbb3f8b52
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/set_permissions_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/set_permissions_command.rbindex a7cabd53ce4..3553c0e2cfe 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/set_permissions_command.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/set_permissions_command.rb@@ -41,35 +41,34 @@ module Storagesdef initialize(storage)@storage = storage- @uri = storage.urienddef call(path:, permissions:)- # permissions should be an hash with "read" and "write" keys with list remote user ids as values- # We need a Patch or Post => already exists or don't exists- # if the collection is empty, the permission will be deleted- permission_set = get_permissions(path).result_or do |error|+ # This could be broken down into:+ # 1. Get Permission IDs+ # 2. Apply Permission Changes+ # 2.1 Create Permissions+ # 2.2 Delete Permissions+ # 2.3 Re-create Permissions+ current_permissions = get_permissions(path).result_or do |error|+ # No reason to continue if we can't access the existing permissionsraise error.to_send- permission_ids = extract_permission_ids(permission_set[:value])+ permission_ids = extract_permission_ids(current_permissions[:value])- permissions.each_key do |permission|- do_things_with(permission.to_s, permissions[permission], permission_ids[permission], path)+ permissions.each_pair do |permission, user_ids|+ apply_permission_changes(permission, user_ids, permission_ids[permission], path)endend- def get_permissions(path)- httpx do |http|- response = http.get(URI.join(@uri, permissions_path(path)))+ private- handle_response(response)- end+ def get_permissions(path)+ httpx { |http| handle_response(http.get(permissions_path(path))) }end- private-- def do_things_with(role, permissions, permission_set_id, item_id)+ def apply_permission_changes(role, permissions, permission_set_id, item_id)return delete_permissions(permission_set_id, item_id) if permissions.empty? && permission_set_idreturn create_permissions(role, permissions, item_id) if permissions.any? && permission_set_id.nil?@@ -96,13 +95,11 @@ module Storagesenddef delete_permissions(permission_set_id, item_id)- httpx do |http|- response = http.delete(permission_path(item_id, permission_set_id))-- handle_response(response)- end+ httpx { |http| handle_response(http.delete(permission_path(item_id, permission_set_id))) }end+ # This will grab the first write or read permission.+ # If the folder is setup correctly this should be enoughdef extract_permission_ids(permission_set)write_permission = permission_set.find(-> { {} }) { |hash| hash[:roles].first == 'write' }[:id]read_permission = permission_set.find(-> { {} }) { |hash| hash[:roles].first == 'read' }[:id]@@ -143,7 +140,7 @@ module StoragesUtil.using_admin_token(@storage) do |token|yield HTTPX.with(- origin: @uri,+ origin: @storage.uri,headers: {authorization: "Bearer #{token}",accept: "application/json",