Skip to content

Commit 2ab65bb

Browse files
committed
feat: fix billing
1 parent a8e32dc commit 2ab65bb

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

apps/backend/src/api/routes/integrations.controller.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import {
2-
Body, Controller, Delete, Get, HttpException, Param, Post, Put, Query, UseFilters
2+
Body,
3+
Controller,
4+
Delete,
5+
Get,
6+
HttpException,
7+
Param,
8+
Post,
9+
Put,
10+
Query,
11+
UseFilters,
312
} from '@nestjs/common';
413
import { ioRedis } from '@gitroom/nestjs-libraries/redis/redis.service';
514
import { ConnectIntegrationDto } from '@gitroom/nestjs-libraries/dtos/integrations/connect.integration.dto';
@@ -483,7 +492,7 @@ export class IntegrationsController {
483492
if (
484493
process.env.STRIPE_PUBLISHABLE_KEY &&
485494
org.isTrailing &&
486-
!!(await this._integrationService.checkPreviousConnections(
495+
(await this._integrationService.checkPreviousConnections(
487496
org.id,
488497
String(id)
489498
))

libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,17 @@ export class IntegrationRepository {
6969
}
7070

7171
async checkPreviousConnections(org: string, id: string) {
72-
const findIt = await this._integration.model.integration.findFirst({
72+
const findIt = await this._integration.model.integration.findMany({
7373
where: {
74-
organizationId: {
75-
not: org,
76-
},
7774
rootInternalId: id.split('_').pop(),
7875
},
76+
select: {
77+
organizationId: true,
78+
id: true,
79+
},
7980
});
8081

81-
return findIt;
82+
return findIt.some((f) => f.organizationId === org) || findIt.length === 0;
8283
}
8384

8485
updateProviderSettings(org: string, id: string, settings: string) {

0 commit comments

Comments
 (0)