diff --git a/packages/api/src/filestorage/folder/services/onedrive/index.ts b/packages/api/src/filestorage/folder/services/onedrive/index.ts index f02db9f95..589480e2e 100644 --- a/packages/api/src/filestorage/folder/services/onedrive/index.ts +++ b/packages/api/src/filestorage/folder/services/onedrive/index.ts @@ -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]; diff --git a/packages/api/src/filestorage/folder/services/onedrive/types.ts b/packages/api/src/filestorage/folder/services/onedrive/types.ts index 725a92f46..3d9448a19 100644 --- a/packages/api/src/filestorage/folder/services/onedrive/types.ts +++ b/packages/api/src/filestorage/folder/services/onedrive/types.ts @@ -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; } /** diff --git a/packages/api/src/filestorage/folder/services/sharepoint/index.ts b/packages/api/src/filestorage/folder/services/sharepoint/index.ts index c2ee70a7b..b83c4bf40 100644 --- a/packages/api/src/filestorage/folder/services/sharepoint/index.ts +++ b/packages/api/src/filestorage/folder/services/sharepoint/index.ts @@ -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]; @@ -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( diff --git a/packages/api/src/filestorage/folder/services/sharepoint/types.ts b/packages/api/src/filestorage/folder/services/sharepoint/types.ts index 5bf8784a4..dcd4a7afb 100644 --- a/packages/api/src/filestorage/folder/services/sharepoint/types.ts +++ b/packages/api/src/filestorage/folder/services/sharepoint/types.ts @@ -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; } /**