Skip to content

Commit

Permalink
Merge branch 'main' into graphile-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
nicktrn committed May 10, 2024
2 parents 32dd68f + c644912 commit 3e19ccf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/webapp/app/services/events/ingestSendEvent.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ export class IngestSendEvent {
try {
const deliverAt = this.#calculateDeliverAt(options);

if (!environment.organization.runsEnabled) {
logger.debug("IngestSendEvent: Runs are disabled for this organization", environment);
return;
}

return await $transaction(this.#prismaClient, async (tx) => {
const externalAccount = options?.accountId
? await tx.externalAccount.upsert({
Expand Down
9 changes: 9 additions & 0 deletions apps/webapp/app/services/runs/startRun.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { $transaction, prisma } from "~/db.server";
import { workerQueue } from "../worker.server";
import { ResumeRunService } from "./resumeRun.server";
import { createHash } from "node:crypto";
import { logger } from "../logger.server";

type FoundRun = NonNullable<Awaited<ReturnType<typeof findRun>>>;
type RunConnectionsByKey = Awaited<ReturnType<typeof createRunConnections>>;
Expand Down Expand Up @@ -36,6 +37,13 @@ export class StartRunService {
}

#runIsStartable(run: FoundRun) {
if (!run.organization.runsEnabled) {
logger.debug("StartRunService: Runs are disabled for this organization", {
organizationId: run.organization.id,
});
return false;
}

const startableStatuses = ["PENDING", "WAITING_ON_CONNECTIONS"] as const;
return startableStatuses.includes(run.status);
}
Expand Down Expand Up @@ -144,6 +152,7 @@ async function findRun(tx: PrismaClientOrTransaction, id: string) {
include: {
queue: true,
environment: true,
organization: true,
version: {
include: {
integrations: {
Expand Down
9 changes: 9 additions & 0 deletions apps/webapp/app/services/sources/handleHttpSource.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { workerQueue } from "../worker.server";
import { requestUrl } from "~/utils/requestUrl.server";
import { RuntimeEnvironmentType } from "@trigger.dev/database";
import { createHttpSourceRequest } from "~/utils/createHttpSourceRequest";
import { logger } from "../logger.server";

export class HandleHttpSourceService {
#prismaClient: PrismaClient;
Expand All @@ -19,6 +20,7 @@ export class HandleHttpSourceService {
endpoint: true,
environment: true,
secretReference: true,
organization: true,
},
});

Expand All @@ -30,6 +32,13 @@ export class HandleHttpSourceService {
return { status: 200 };
}

if (!triggerSource.organization.runsEnabled) {
logger.debug("HandleHttpSourceService: Runs are disabled for this organization", {
organizationId: triggerSource.organization.id,
});
return { status: 404 };
}

if (!triggerSource.interactive) {
const sourceRequest = await createHttpSourceRequest(request);

Expand Down

0 comments on commit 3e19ccf

Please sign in to comment.