📈 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
Implemented a route to update the subscribers of the project
Yevhenii Kulisidi76749b28eb30
diff --git a/src/project/project.controller.ts b/src/project/project.controller.tsindex 11d64c4a2..c7ef46c58 100644--- a/src/project/project.controller.ts+++ b/src/project/project.controller.ts@@ -901,11 +901,35 @@ export class ProjectController {}@Patch(':projectId/subscribers/:subscriberId')+ @Auth([UserType.ADMIN, UserType.CUSTOMER])async updateSubscriber(@Param() params: UpdateSubscriberParamsDto,@Body() body: UpdateSubscriberBodyDto,- ): Promise<void> {- // TODO: Implement+ @CurrentUserId() userId: string,+ ) {+ const project = await this.projectService.getProject(+ params.projectId,+ userId,+ )++ if (!project) {+ throw new NotFoundException('Project not found.')+ }++ const subscriber = await this.projectService.getSubscriber(+ params.projectId,+ params.subscriberId,+ )++ if (!subscriber) {+ throw new NotFoundException('Subscriber not found.')+ }++ return await this.projectService.updateSubscriber(+ params.projectId,+ params.subscriberId,+ body,+ )}@Delete(':projectId/subscribers/:subscriberId')diff --git a/src/project/project.service.ts b/src/project/project.service.tsindex 2640fed61..94616012a 100644--- a/src/project/project.service.ts+++ b/src/project/project.service.ts@@ -47,7 +47,7 @@ import { ActionTokenType } from 'src/action-tokens/action-token.entity'import { MailerService } from 'src/mailer/mailer.service'import { LetterTemplate } from 'src/mailer/letter'import { AddSubscriberType } from './types'-import { GetSubscribersQueriesDto } from './dto'+import { GetSubscribersQueriesDto, UpdateSubscriberBodyDto } from './dto'dayjs.extend(utc)@@ -523,4 +523,17 @@ export class ProjectService {return { subscribers, count }}++ async updateSubscriber(+ projectId: string,+ subscriberId: string,+ data: UpdateSubscriberBodyDto,+ ) {+ await this.projectSubscriberRepository.update(+ { id: subscriberId, projectId },+ data,+ )++ return await this.getSubscriber(projectId, subscriberId)+ }}