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
Starting to clean up the mess
Marcello Rocha12e3f2913cee
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 ef36a574180..a7cabd53ce4 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@@ -48,11 +48,11 @@ module Storages# 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|- raise "And it was when, they knew they had fucked up"+ permission_set = get_permissions(path).result_or do |error|+ raise error.to_send- permission_ids = extract_permission_ids(permission_set)+ permission_ids = extract_permission_ids(permission_set[:value])permissions.each_key do |permission|do_things_with(permission.to_s, permissions[permission], permission_ids[permission], path)@@ -63,18 +63,7 @@ module Storageshttpx do |http|response = http.get(URI.join(@uri, permissions_path(path)))- case response.status- when 200..299- ServiceResult.success(result: response.json(symbolize_keys: true).fetch(:value))- when 401- ServiceResult.failure(result: :unauthorized)- when 403- ServiceResult.failure(result: :forbidden)- when 404- ServiceResult.failure(result: :not_found)- else- ServiceResult.failure(result: :panic)- end+ handle_response(response)endend@@ -84,7 +73,6 @@ module Storagesreturn 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?- # create_permissions(role, permissions, item_id)update_permissions(role, permissions, permission_set_id, item_id)end@@ -103,12 +91,7 @@ module Storagesrecipients: drive_recipients}.to_json)- case response.status- when 200- response.json(symbolize_keys: true)- else- raise "Panic at the Team"- end+ handle_response(response)endend@@ -116,11 +99,7 @@ module Storageshttpx do |http|response = http.delete(permission_path(item_id, permission_set_id))- if response.status == 204- ServiceResult.success- else- ServiceResult.failure- end+ handle_response(response)endend@@ -131,6 +110,23 @@ module Storages{ read: read_permission, write: write_permission }end+ def handle_response(response)+ case response+ in { status: 200 }+ ServiceResult.success(result: response.json(symbolize_keys: true))+ in { status: 204 }+ ServiceResult.success+ in { status: 401 }+ ServiceResult.failure(result: :unauthorized)+ in { status: 403 }+ ServiceResult.failure(result: :forbidden)+ in { status: 404 }+ ServiceResult.failure(result: :not_found)+ else+ ServiceResult.failure(result: :error)+ end+ end+def permission_path(item_id, permission_id)"#{permissions_path(item_id)}/#{permission_id}"end