π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
feat: delete channel
Nevo David02ffca06c492
diff --git a/apps/backend/src/api/routes/integrations.controller.ts b/apps/backend/src/api/routes/integrations.controller.tsindex e509aba35..d3058a992 100644--- a/apps/backend/src/api/routes/integrations.controller.ts+++ b/apps/backend/src/api/routes/integrations.controller.ts@@ -31,7 +31,7 @@ import { NotEnoughScopesFilter } from '@gitroom/nestjs-libraries/integrations/inexport class IntegrationsController {constructor(private _integrationManager: IntegrationManager,- private _integrationService: IntegrationService+ private _integrationService: IntegrationService,) {}@Get('/')getIntegration() {@@ -293,7 +293,6 @@ export class IntegrationsController {@GetOrgFromRequest() org: Organization,@Body('id') id: string) {- // @ts-ignorereturn this._integrationService.deleteChannel(org.id, id);}}diff --git a/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts b/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.tsindex 4c9677b66..4762cb854 100644--- a/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts+++ b/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts@@ -187,8 +187,9 @@ export class IntegrationRepository {});}- countPostsForChannel(org: string, id: string) {- return this._posts.model.post.count({+ getPostsForChannel(org: string, id: string) {+ return this._posts.model.post.groupBy({+ by: ['group'],where: {organizationId: org,integrationId: id,diff --git a/libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts b/libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.tsindex 2f201b73f..f21c09cee 100644--- a/libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts+++ b/libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts@@ -7,13 +7,15 @@ import { SocialProvider } from '@gitroom/nestjs-libraries/integrations/social/soimport { Integration } from '@prisma/client';import { NotificationService } from '@gitroom/nestjs-libraries/database/prisma/notifications/notification.service';import { LinkedinPageProvider } from '@gitroom/nestjs-libraries/integrations/social/linkedin.page.provider';+import { PostsService } from '@gitroom/nestjs-libraries/database/prisma/posts/posts.service';@Injectable()export class IntegrationService {constructor(private _integrationRepository: IntegrationRepository,private _integrationManager: IntegrationManager,- private _notificationService: NotificationService+ private _notificationService: NotificationService,+ private _postsService: PostsService) {}createOrUpdateIntegration(org: string,@@ -143,15 +145,14 @@ export class IntegrationService {}async deleteChannel(org: string, id: string) {- const isTherePosts = await this._integrationRepository.countPostsForChannel(+ const isTherePosts = await this._integrationRepository.getPostsForChannel(org,id);- if (isTherePosts) {- throw new HttpException(- 'There are posts for this channel',- HttpStatus.NOT_ACCEPTABLE- );+ if (isTherePosts.length) {+ for (const post of isTherePosts) {+ await this._postsService.deletePost(org, post.group);+ }}return this._integrationRepository.deleteChannel(org, id);@@ -217,7 +218,10 @@ export class IntegrationService {page);- await this.checkForDeletedOnceAndUpdate(org, String(getIntegrationInformation.id));+ await this.checkForDeletedOnceAndUpdate(+ org,+ String(getIntegrationInformation.id)+ );await this._integrationRepository.updateIntegration(String(id), {picture: getIntegrationInformation.picture,