diff options
Diffstat (limited to 'pages/api/po/webhook.ts')
| -rw-r--r-- | pages/api/po/webhook.ts | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/pages/api/po/webhook.ts b/pages/api/po/webhook.ts index e61246a2..39a6931e 100644 --- a/pages/api/po/webhook.ts +++ b/pages/api/po/webhook.ts @@ -3,15 +3,11 @@ export const config = { bodyParser: true, // ✅ 이게 false면 안 됨! }, }; - import type { NextApiRequest, NextApiResponse } from "next"; import path from "path"; import fs from "fs"; import * as z from "zod"; import db from "@/db/db"; -import { GetPOSchema } from "@/lib/po/validations"; -import { unstable_cache } from "@/lib/unstable-cache"; -import { filterColumns } from "@/lib/filter-columns"; import { asc, desc, @@ -25,18 +21,15 @@ import { eq, count, } from "drizzle-orm"; -import { countPos, selectPos } from "@/lib/po/repository"; import { contractEnvelopes, - contractsDetailView, contractSigners, contracts, } from "@/db/schema/contract"; -import { vendors, vendorContacts } from "@/db/schema/vendors"; -import dayjs from "dayjs"; - -import { POContent } from "@/lib/docuSign/types"; -import { downloadContractFile, getRecipients } from "@/lib/docuSign/docuSignFns"; +import { + downloadContractFile, + getRecipients, +} from "@/lib/docuSign/docuSignFns"; export default async function handler( req: NextApiRequest, @@ -108,7 +101,7 @@ export default async function handler( await tx .update(contracts) - .set({ status: `$FAILED_${safeRole}_SEND_MAIL(${message})` }) + .set({ status: `FAILED_${safeRole}_SEND_MAIL(${message})` }) .where(eq(contracts.id, contractId)); await tx @@ -154,6 +147,10 @@ export default async function handler( .where(eq(dbSchma.envelopeId, envelopeId)) .limit(1); + if (!targetContract) { + continue; + } + const { id, contractId } = targetContract; if (contractId === null || contractId === undefined) { @@ -210,6 +207,10 @@ export default async function handler( .where(eq(dbSchma.envelopeId, envelopeId)) .limit(1); + if (!targetContract) { + continue; + } + const { id, contractId, fileName, filePath } = targetContract; if (contractId === null || contractId === undefined) { @@ -277,6 +278,10 @@ export default async function handler( .where(eq(dbSchma.envelopeId, envelopeId)) .limit(1); + if (!targetContract) { + continue; + } + const { contractId, fileName, filePath } = targetContract; if (contractId === null || contractId === undefined) { |
