fix: types

This commit is contained in:
Henry
2026-02-27 15:14:10 +00:00
parent 1d6825b181
commit 4224a38ac4

View File

@@ -2,8 +2,8 @@ import crypto from "crypto";
import { z } from "zod";
import type { dbClient } from "@kan/db/client";
import * as webhookRepo from "@kan/db/repository/webhook.repo";
import type { WebhookEvent } from "@kan/db/schema";
import * as webhookRepo from "@kan/db/repository/webhook.repo";
export type WebhookEventType = WebhookEvent;
@@ -92,7 +92,7 @@ export const webhookUrlSchema = z
(url) => {
try {
const hostname = new URL(url).hostname.toLowerCase();
const ipv4Match = hostname.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
const ipv4Match = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.exec(hostname);
if (ipv4Match) {
const [, a, b] = ipv4Match.map(Number);
if (
@@ -185,15 +185,16 @@ export async function sendWebhooksForWorkspace(
payload: WebhookPayload,
): Promise<void> {
try {
// Get active webhooks for this workspace, pre-filtered by event at the DB level
const webhooks = await webhookRepo.getActiveByWorkspaceId(
db,
workspaceId,
payload.event,
// Get active webhooks for this workspace
const webhooks = await webhookRepo.getActiveByWorkspaceId(db, workspaceId);
// Filter webhooks that are subscribed to this specific event
const webhooksForEvent = webhooks.filter((webhook) =>
webhook.events.includes(payload.event),
);
// Send to all webhooks in parallel (fire and forget)
const promises = webhooks.map((webhook) =>
// Send to all subscribed webhooks in parallel (fire and forget)
const promises = webhooksForEvent.map((webhook) =>
sendWebhookToUrl(webhook.url, webhook.secret ?? undefined, payload).then(
(result) => {
if (!result.success) {