Skip to content

Commit

Permalink
Merge pull request #176 from internxt/feat/return-shared-folders
Browse files Browse the repository at this point in the history
[_]: feat/return shared with/by folders together
  • Loading branch information
sg-gs authored Jul 20, 2023
2 parents 7ad1852 + a62bb81 commit bc920cb
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/modules/private-share-folder/private-sharing.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,58 @@ export class PrivateSharingController {
throw error;
}
}

@Get('/folders')
@ApiOperation({
summary: 'Get all folders shared by a user',
})
@ApiQuery({
description: 'Number of page to take by ( default 0 )',
name: 'page',
required: false,
type: Number,
})
@ApiQuery({
description: 'Number of items per page ( default 50 )',
name: 'perPage',
required: false,
type: Number,
})
@ApiQuery({
description: 'Order by',
name: 'orderBy',
required: false,
type: String,
})
@ApiOkResponse({ description: 'Get all folders shared by/with a user' })
@ApiBearerAuth()
async getAllSharedFolders(
@UserDecorator() user: User,
@Query('orderBy') orderBy: OrderBy,
@Query('page') page = 0,
@Query('perPage') perPage = 50,
): Promise<Record<'sharedByMe' | 'sharedWithMe', Folder[]>> {
const { offset, limit } = Pagination.calculatePagination(page, perPage);

const order = orderBy
? [orderBy.split(':') as [string, string]]
: undefined;

return {
sharedByMe: await this.privateSharingUseCase.getSharedFoldersByOwner(
user,
offset,
limit,
order,
),

sharedWithMe:
await this.privateSharingUseCase.getSharedFoldersBySharedWith(
user,
offset,
limit,
order,
),
};
}
}

0 comments on commit bc920cb

Please sign in to comment.