📈 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
some improvements
Blue Mouse4898e44594a8
diff --git a/src/marketplace/extensions/entities/extension.entity.ts b/src/marketplace/extensions/entities/extension.entity.tsindex 28773878e..365091dd6 100644--- a/src/marketplace/extensions/entities/extension.entity.ts+++ b/src/marketplace/extensions/entities/extension.entity.ts@@ -20,13 +20,10 @@ import { Complaint } from '../../complaints/entities/complaint.entity'@Entity()export class Extension {@PrimaryGeneratedColumn('uuid')- id!: string-- // @Column('uuid')- // ownerId: string+ id: string@ManyToOne(() => User, user => user.ownedExtensions)- owner!: User+ owner: User@Column('varchar')name: stringdiff --git a/src/marketplace/extensions/extensions.controller.ts b/src/marketplace/extensions/extensions.controller.tsindex 0225aca71..cdbf32dea 100644--- a/src/marketplace/extensions/extensions.controller.ts+++ b/src/marketplace/extensions/extensions.controller.ts@@ -384,15 +384,14 @@ export class ExtensionsController {@Patch(':extensionId')async updateExtension(@Param() params: UpdateExtensionParams,+ @CurrentUserId() userId: string,@Body(new BodyValidationPipe()) body: UpdateExtension,): Promise<UpdateExtension> {- const extension = await this.extensionsService.findById(params.extensionId)+ const { extensionId } = params- if (!extension) {- throw new NotFoundException('Extension not found.')- }+ this.extensionsService.allowedToManage(userId, extensionId)- await this.extensionsService.update(extension.id, body)+ await this.extensionsService.update(extensionId, body)return body}@@ -404,14 +403,15 @@ export class ExtensionsController {type: String,})@Delete(':extensionId')- async deleteExtension(@Param() params: DeleteExtensionParams): Promise<void> {- const extension = await this.extensionsService.findById(params.extensionId)+ async deleteExtension(+ @Param() params: DeleteExtensionParams,+ @CurrentUserId() userId: string,+ ): Promise<void> {+ const { extensionId } = params- if (!extension) {- throw new NotFoundException('Extension not found.')- }+ this.extensionsService.allowedToManage(userId, extensionId)- await this.extensionsService.delete(extension.id)+ await this.extensionsService.delete(extensionId)}@Post(':extensionId/install')diff --git a/src/marketplace/extensions/extensions.service.ts b/src/marketplace/extensions/extensions.service.tsindex c9c0bb210..c3e59d98c 100644--- a/src/marketplace/extensions/extensions.service.ts+++ b/src/marketplace/extensions/extensions.service.ts@@ -1,4 +1,4 @@-import { Injectable } from '@nestjs/common'+import { ForbiddenException, Injectable } from '@nestjs/common'import { InjectRepository } from '@nestjs/typeorm'import { FindManyOptions, FindOneOptions, Repository } from 'typeorm'import { ExtensionToProject } from './entities/extension-to-project.entity'@@ -121,6 +121,19 @@ export class ExtensionsService {// return this.InstallExtensionRepository.findOne(id, params)// }+ async allowedToManage(+ ownerId: string,+ id: string,+ ): Promise<any> {+ const extension = await this.findOne({+ where: { owner: ownerId, id },+ })++ if (!extension) {+ throw new ForbiddenException('You are not allowed to manage this extension')+ }+ }+async save(extension: ISaveExtension): Promise<ISaveExtension & Extension> {return await this.extensionRepository.save(extension)}