Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
c27gc committed Jul 11, 2023
1 parent 6b47e9c commit 19dbc37
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/modules/private-share-folder/private-sharing.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,62 @@ export class PrivateSharingController {
throw error;
}
}

@Get('items/:privateSharingFolderId')
@ApiOperation({
summary: 'Get all items 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 items shared by a user' })
@ApiBearerAuth()
async getSharedItems(
@UserDecorator() user: User,
@Param('privateSharingFolderId') privateSharingFolderId: string,
@Query('orderBy') orderBy: OrderBy,
@Query('page') page = 0,
@Query('perPage') perPage = 50,
): Promise<{ folders: Folder[]; files: File[] }> {
try {
const { offset, limit } = Pagination.calculatePagination(page, perPage);

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

return {
folders: await this.privateSharingUseCase.getSharedFoldersByOwner(
user,
offset,
limit,
order,
),
};
} catch (error) {
const err = error as Error;
Logger.error(
`[PRIVATESHARING/GETSHAREDBY] Error while getting shared folders by user ${
user.uuid
}, ${err.stack || 'No stack trace'}`,
);

throw error;
}
}
}

0 comments on commit 19dbc37

Please sign in to comment.