feat: fix billing

This commit is contained in:
Nevo David 2025-08-09 20:29:13 +07:00
parent a8e32dc399
commit 2ab65bb375
2 changed files with 17 additions and 7 deletions

View File

@ -1,5 +1,14 @@
import {
Body, Controller, Delete, Get, HttpException, Param, Post, Put, Query, UseFilters
Body,
Controller,
Delete,
Get,
HttpException,
Param,
Post,
Put,
Query,
UseFilters,
} from '@nestjs/common';
import { ioRedis } from '@gitroom/nestjs-libraries/redis/redis.service';
import { ConnectIntegrationDto } from '@gitroom/nestjs-libraries/dtos/integrations/connect.integration.dto';
@ -483,7 +492,7 @@ export class IntegrationsController {
if (
process.env.STRIPE_PUBLISHABLE_KEY &&
org.isTrailing &&
!!(await this._integrationService.checkPreviousConnections(
(await this._integrationService.checkPreviousConnections(
org.id,
String(id)
))

View File

@ -69,16 +69,17 @@ export class IntegrationRepository {
}
async checkPreviousConnections(org: string, id: string) {
const findIt = await this._integration.model.integration.findFirst({
const findIt = await this._integration.model.integration.findMany({
where: {
organizationId: {
not: org,
},
rootInternalId: id.split('_').pop(),
},
select: {
organizationId: true,
id: true,
},
});
return findIt;
return findIt.some((f) => f.organizationId === org) || findIt.length === 0;
}
updateProviderSettings(org: string, id: string, settings: string) {