Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Allow querying customers by externalId

Steven Teyd141493fcbfa
diff --git a/apps/web/lib/api/customers/get-customer-or-throw.ts b/apps/web/lib/api/customers/get-customer-or-throw.ts
index 72058b253b..d5026ad732 100644
--- a/apps/web/lib/api/customers/get-customer-or-throw.ts
+++ b/apps/web/lib/api/customers/get-customer-or-throw.ts
@@ -9,7 +9,16 @@ export const getCustomerOrThrow = async ({
workspaceId: string;
}) => {
const customer = await prisma.customer.findUnique({
- where: { id },
+ where: {
+ ...(id.startsWith("ext_")
+ ? {
+ projectId_externalId: {
+ projectId: workspaceId,
+ externalId: id.replace("ext_", ""),
+ },
+ }
+ : { id }),
+ },
});
if (!customer || customer.projectId !== workspaceId) {