Files
triggerdotdev--trigger.dev/apps/webapp/app/v3/services/createOrgIntegration.server.ts
Saadi Myftija 2dbc085bb3 Fix alert creation bug related to the Slack integration (#1967)
* Fix alert creation bug related to the Slack integration

* Handle token_expired error from slack gracefully
2025-04-23 11:11:17 +01:00

31 lines
783 B
TypeScript

import { OrganizationIntegration } from "@trigger.dev/database";
import { BaseService } from "./baseService.server";
import { OrgIntegrationRepository } from "~/models/orgIntegration.server";
export class CreateOrgIntegrationService extends BaseService {
public async call(
userId: string,
orgId: string,
serviceName: string,
code: string
): Promise<OrganizationIntegration | undefined> {
// Get the org
const org = await this._prisma.organization.findUnique({
where: {
id: orgId,
members: {
some: {
userId,
},
},
},
});
if (!org) {
throw new Error("Organization not found");
}
return OrgIntegrationRepository.createOrgIntegration(serviceName, code, org);
}
}