Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

added TODO and some code

Blue Mouse3aba4dd17c51
diff --git a/src/project/project.controller.ts b/src/project/project.controller.ts
index cae424b67..a570c31e7 100644
--- a/src/project/project.controller.ts
+++ b/src/project/project.controller.ts
@@ -475,6 +475,37 @@ export class ProjectController {
): Promise<any> {
this.logger.log({ uid, pid, shareDTO }, 'POST /project/:pid/share')
- // TODO
+ /*
+ TODO:
+ 1. Validate the PID +
+ 2. Validate ShareDTO
+ 3. Check if the user is the owner of the project +
+ 4. Check if the user you want to share project with already has the project
+ 5. Add the user to the project with confirmed = false
+ 6. Send an email to the user with a link to confirm the share (the email is valid for 48 hours)
+ 7. Return the project
+ */
+ if (!isValidPID(pid)) {
+ throw new BadRequestException(
+ 'The provided Project ID (pid) is incorrect',
+ )
+ }
+
+ const user = await this.userService.findOne(uid)
+ const project = await this.projectService.findOneWhere(
+ { id: pid },
+ {
+ relations: ['admin', 'share'],
+ select: ['id', 'admin', 'share'],
+ },
+ )
+
+ if (_isEmpty(project)) {
+ throw new NotFoundException(`Project with ID ${pid} does not exist`)
+ }
+
+ this.projectService.allowedToManage(project, uid, user.roles)
+
+ // const share = new Share()
}
}