📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
added mock update share
Blue Mouse2d574dad033a
diff --git a/src/project/dto/share-update.dto.ts b/src/project/dto/share-update.dto.tsnew file mode 100644index 000000000..50f66b252--- /dev/null+++ b/src/project/dto/share-update.dto.ts@@ -0,0 +1,14 @@+import { ApiProperty } from '@nestjs/swagger'+import { IsNotEmpty } from 'class-validator'++import { Role } from '../entity/project-share.entity'++export class ShareUpdateDTO {+ @ApiProperty({+ example: 'viewer',+ required: true,+ description: 'Users role in your project',+ })+ @IsNotEmpty()+ role: Role+}diff --git a/src/project/project.controller.ts b/src/project/project.controller.tsindex 4d6d2e8d1..67671bb26 100644--- a/src/project/project.controller.ts+++ b/src/project/project.controller.ts@@ -38,6 +38,7 @@ import { CurrentUserId } from '../common/decorators/current-user-id.decorator'import { UserService } from '../user/user.service'import { ProjectDTO } from './dto/project.dto'import { ShareDTO } from './dto/share.dto'+import { ShareUpdateDTO } from './dto/share-update.dto'import { AppLoggerService } from '../logger/logger.service'import {redis,@@ -89,6 +90,10 @@ const isValidShareDTO = (share: ShareDTO): boolean => {)}+const isValidUpdateShareDTO = (share: ShareUpdateDTO): boolean => {+ return _includes(roles, share.role)+}+@ApiTags('Project')@Controller('project')export class ProjectController {@@ -607,6 +612,40 @@ export class ProjectController {}}+ @Put('/share/:shareId')+ @HttpCode(200)+ @UseGuards(SelfhostedGuard)+ @UseGuards(RolesGuard)+ @Roles(UserType.CUSTOMER, UserType.ADMIN)+ @ApiResponse({ status: 200, type: Project })+ async updateShare(+ @Param('shareId') shareId: string,+ @Body() shareDTO: ShareUpdateDTO,+ @CurrentUserId() uid: string,+ ): Promise<any> {+ this.logger.log({ uid, shareDTO, shareId }, 'PUT /project/:pid/share')+ if (!isValidUpdateShareDTO(shareDTO)) {+ throw new BadRequestException(+ 'The provided ShareUpdateDTO 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)+ }+@HttpCode(204)@UseGuards(SelfhostedGuard)// @UseGuards(RolesGuard)