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

Consider drive root to be a folder when syncing onedrive/sharepoint #703

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/api/src/filestorage/folder/services/onedrive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,20 @@ export class OnedriveService implements IFolderService {
},
});

let result = [],
// get root folder
const rootFolderData = await axios.get(
`${connection.account_url}/v1.0/me/drive/root`,
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.cryptoService.decrypt(
connection.access_token,
)}`,
},
},
);

let result = [rootFolderData.data],
depth = 0,
batch = [remote_folder_id];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export interface OnedriveFolderInput {
readonly createdBy?: IdentitySet;
/** Identity of the user, device, and application that last modified the item. Read-only. */
readonly lastModifiedBy?: IdentitySet;
/** If this property is non-null, it indicates that the driveItem is the top-most driveItem in the drive. */
readonly root?: any;
Comment on lines +58 to +59
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM! Consider using a more specific type if possible.

The addition of the root property enhances the OnedriveFolderInput interface by providing additional context about the state of the driveItem. The read-only nature of the property aligns with its purpose of indicating the top-most item in the drive hierarchy. The comment provides a clear explanation of the property's purpose, which is helpful for developers using this interface.

However, consider using a more specific type than any for the root property if possible, as it may provide better type safety and improve code maintainability.

}

/**
Expand Down
17 changes: 15 additions & 2 deletions packages/api/src/filestorage/folder/services/sharepoint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,20 @@ export class SharepointService implements IFolderService {
},
});

let result = [],
// get root folder
const rootFolderData = await axios.get(
`${connection.account_url}/drive/root`,
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.cryptoService.decrypt(
connection.access_token,
)}`,
},
},
);

let result = [rootFolderData.data],
depth = 0,
batch = [remote_folder_id];

Expand All @@ -104,7 +117,7 @@ export class SharepointService implements IFolderService {
},
);

// Add permissions (shared link is also included in permissions in one-drive)
// Add permissions (shared link is also included in permissions in SharePoint)
// await Promise.all(
// resp.data.value.map(async (driveItem) => {
// const resp = await axios.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export interface SharepointFolderInput {
readonly createdBy?: IdentitySet;
/** Identity of the user, device, and application that last modified the item. Read-only. */
readonly lastModifiedBy?: IdentitySet;
/** If this property is non-null, it indicates that the driveItem is the top-most driveItem in the drive. */
readonly root?: any;
Comment on lines +58 to +59
Copy link
Contributor

Choose a reason for hiding this comment

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

Approve the addition of the root property, but consider defining a specific type.

The new root property enhances the SharepointFolderInput interface by allowing it to indicate whether the associated driveItem is the top-most item in the drive. This addition improves the interface's ability to represent the SharePoint folder structure accurately.

However, the any type for the root property might lead to inconsistencies or confusion. Consider defining a specific type, such as boolean, to clearly convey the expected values and improve type safety.

}

/**
Expand Down
Loading