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!

moar

Blue Moused03d41832600
diff --git a/src/project/dto/share.dto.ts b/src/project/dto/share.dto.ts
index e8ac6209e..ba04ba7a0 100644
--- a/src/project/dto/share.dto.ts
+++ b/src/project/dto/share.dto.ts
@@ -1,6 +1,8 @@
import { ApiProperty } from '@nestjs/swagger'
import { IsNotEmpty } from 'class-validator'
+import { Role } from '../entity/project-share.entity'
+
export class ShareDTO {
@ApiProperty({
example: '[email protected]',
@@ -16,5 +18,5 @@ export class ShareDTO {
description: 'Users role in your project',
})
@IsNotEmpty()
- role: string
+ role: Role
}
diff --git a/src/project/entity/project-share.entity.ts b/src/project/entity/project-share.entity.ts
index 227186a53..e2f437c6b 100644
--- a/src/project/entity/project-share.entity.ts
+++ b/src/project/entity/project-share.entity.ts
@@ -4,7 +4,7 @@ import { ApiProperty } from '@nestjs/swagger'
import { User } from '../../user/entities/user.entity'
import { Project } from './project.entity'
-export enum PlanCode {
+export enum Role {
viewer = 'viewer',
admin = 'admin',
}
@@ -29,9 +29,9 @@ export class ProjectShare {
@Column({
type: 'enum',
- enum: PlanCode,
+ enum: Role,
})
- role: PlanCode
+ role: Role
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
created: Date
diff --git a/src/project/project.controller.ts b/src/project/project.controller.ts
index 3eed561be..21f17c182 100644
--- a/src/project/project.controller.ts
+++ b/src/project/project.controller.ts
@@ -27,6 +27,7 @@ import { SelfhostedGuard } from 'src/common/guards/selfhosted.guard'
import { RolesGuard } from '../common/guards/roles.guard'
import { Pagination } from '../common/pagination/pagination'
import { Project } from './entity/project.entity'
+import { ProjectShare } from './entity/project-share.entity'
import { CurrentUserId } from '../common/decorators/current-user-id.decorator'
import { UserService } from '../user/user.service'
import { ProjectDTO } from './dto/project.dto'
@@ -510,6 +511,32 @@ export class ProjectController {
this.projectService.allowedToManage(project, uid, user.roles)
- // const share = new Share()
+ try {
+ const share = new ProjectShare()
+ share.role = shareDTO.role
+ // todo
+
+
+ // const project = new Project()
+ // Object.assign(project, projectDTO)
+ // project.origins = _map(projectDTO.origins, _trim)
+
+ // const newProject = await this.projectService.create(project)
+ // user.projects.push(project)
+
+ // await this.userService.create(user)
+
+ // return newProject
+ } catch (e) {
+ // if (e.code === 'ER_DUP_ENTRY') {
+ // if (e.sqlMessage.includes(projectDTO.id)) {
+ // throw new BadRequestException(
+ // 'Project with selected ID already exists',
+ // )
+ // }
+ // }
+
+ // throw new BadRequestException(e)
+ }
}
}