Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements the OneDrive Sync Service #14648

Merged
merged 4 commits into from
Feb 2, 2024
Merged

Conversation

mereghost
Copy link
Contributor

@mereghost mereghost commented Jan 25, 2024

What?

This PR introduces the OneDriveSyncService as required by the OP#52394. The objective here being creating a similar service to the one used by Nextcloud - NextcloudGroupFolderSyncService, formerly known as GroupFolderPropertiesSyncService.

What it should do?

  1. Create a project folders at the File Storage root folder
  2. Rename any "misnamed" folder (ensure that the current project name is used)
  3. Add and remove logged in users so that the permissions match (as close as possible) to the ones in OP
  4. Hide any inactive project folders.

Why?

This is one of the final pieces needed for the Automatically Managed Project Folders on OneDrive/SharePoint and intends to ensure feature parity between SharePoint and Nextcloud.

How?

I will go through the order of operations here:

  1. Early exit if, somehow, the storage passed has automatically_managed set to false

  2. Get all existing folders, their names and IDs: this information is parsed and just the ID/name tuples are returned. If an error occurs here, we need to terminate in an error state as, probably, the credentials are broken or the storage mis-configured.

  3. Following this we ensure that the folders do exist by:

    1. Creating the folders if the project doesn't have one associated with it or it cannot be found.
    2. Renaming the folder if needed (i.e. the project changed name)
  4. And then we hide the inactive project folders. Hiding a folder just means removing everyone's access from it.

None of these operations warrant an early exit and will be logged by the Rails Logger in case some error happens using the structure:

{ 
    "command" : "Storages::Peripherals::StorageInteraction::OneDrive::SetPermissionsCommand",
    "message" : "Outbound request unauthorized",
    "data" : { "status" : "401", "body" : "response body" }
}

From there we can move to setting permissions. On Sharepoint/OneDrive there's only 2 levels of access we can grant: read and write. So, when mapping to OpenProject permission system, I only grant read permissions if the only file related permission given is read_file and write if the user has access to write_files, this implies the share_files, delete_files are also given.

When applying the new permissions we ensure that the OpenProject Admin has full write access to the folder and we loop through all the users checking their permissions and creating the hash argument for the SetPermissionsCommand. Any errors here will also be logged by the Rails Logger.

@mereghost mereghost requested review from apfohl, ba1ash, Kharonus and a team January 25, 2024 15:03
@mereghost mereghost self-assigned this Jan 25, 2024
@mereghost mereghost force-pushed the impl/sharepoint-sync-service branch 4 times, most recently from d9c9ca6 to e2a30b8 Compare January 30, 2024 11:37
- Adds VCR options for re-recording and filtering sensitive data
- Adds error handling to Util.using_admin_token
- Improves logging of multiple commands
@mereghost mereghost force-pushed the impl/sharepoint-sync-service branch from 4088380 to 03d5664 Compare January 30, 2024 17:47
@mereghost mereghost marked this pull request as ready for review January 30, 2024 17:47
@mereghost mereghost changed the title [WIP] Implements the OneDrive Sync Service Implements the OneDrive Sync Service Jan 30, 2024
Copy link
Member

@Kharonus Kharonus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting it to "request changes", even with me not seeing a big blocker.

but there are a few points, I'd at least like to discuss first.

@mereghost mereghost merged commit 16c1253 into dev Feb 2, 2024
9 checks passed
@mereghost mereghost deleted the impl/sharepoint-sync-service branch February 2, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants