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!

Implemented a route to remove project subscribers

Yevhenii Kulisidi246c2e6285f5
diff --git a/src/project/project.controller.ts b/src/project/project.controller.ts
index c7ef46c58..1fb621a8d 100644
--- a/src/project/project.controller.ts
+++ b/src/project/project.controller.ts
@@ -933,9 +933,32 @@ export class ProjectController {
}
@Delete(':projectId/subscribers/:subscriberId')
+ @Auth([UserType.ADMIN, UserType.CUSTOMER])
async removeSubscriber(
@Param() params: RemoveSubscriberParamsDto,
+ @CurrentUserId() userId: string,
): Promise<void> {
- // TODO: Implement
+ 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.')
+ }
+
+ await this.projectService.removeSubscriber(
+ params.projectId,
+ params.subscriberId,
+ )
}
}
diff --git a/src/project/project.service.ts b/src/project/project.service.ts
index 94616012a..4518f7248 100644
--- a/src/project/project.service.ts
+++ b/src/project/project.service.ts
@@ -536,4 +536,11 @@ export class ProjectService {
return await this.getSubscriber(projectId, subscriberId)
}
+
+ async removeSubscriber(projectId: string, subscriberId: string) {
+ await this.projectSubscriberRepository.delete({
+ id: subscriberId,
+ projectId,
+ })
+ }
}