Skip to content

Commit

Permalink
🚀 remove screenshot free user
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultleouay committed Nov 6, 2024
1 parent 9ec099a commit 9579678
Showing 1 changed file with 34 additions and 17 deletions.
51 changes: 34 additions & 17 deletions apps/server/src/checker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Hono } from "hono";
import { z } from "zod";

import { and, db, eq, isNull, schema } from "@openstatus/db";
import { incidentTable } from "@openstatus/db/src/schema";
import { incidentTable, workspace } from "@openstatus/db/src/schema";
import {
monitorStatusSchema,
selectMonitorSchema,
Expand Down Expand Up @@ -189,18 +189,26 @@ checkerRoute.post("/updateStatus", async (c) => {
.select({
url: schema.monitor.url,
jobType: schema.monitor.jobType,
workspaceId: schema.monitor.workspaceId,
})
.from(schema.monitor)
.where(eq(schema.monitor.id, Number(monitorId)))
.get();
if (monitor && monitor.jobType === "http") {
await triggerScreenshot({
data: {
url: monitor.url,
incidentId: newIncident[0].id,
kind: "incident",
},
});
if (monitor && monitor.jobType === "http" && monitor.workspaceId) {
const currentWorkspace = await db
.select()
.from(workspace)
.where(eq(workspace.id, monitor.workspaceId))
.get();
if (currentWorkspace?.plan !== "free") {
await triggerScreenshot({
data: {
url: monitor.url,
incidentId: newIncident[0].id,
kind: "incident",
},
});
}
}
}
}
Expand Down Expand Up @@ -282,18 +290,27 @@ checkerRoute.post("/updateStatus", async (c) => {
.select({
url: schema.monitor.url,
jobType: schema.monitor.jobType,
workspaceId: schema.monitor.workspaceId,
})
.from(schema.monitor)
.where(eq(schema.monitor.id, Number(monitorId)))
.get();
if (monitor && monitor.jobType === "http") {
await triggerScreenshot({
data: {
url: monitor.url,
incidentId: incident.id,
kind: "recovery",
},
});
if (monitor && monitor.jobType === "http" && monitor.workspaceId) {
const currentWorkspace = await db
.select()
.from(workspace)
.where(eq(workspace.id, monitor.workspaceId))
.get();

if (currentWorkspace?.plan !== "free") {
await triggerScreenshot({
data: {
url: monitor.url,
incidentId: incident.id,
kind: "recovery",
},
});
}
}
}
}
Expand Down

0 comments on commit 9579678

Please sign in to comment.