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.

Queue an email when a submitted lead comment is posted

Rafi166388cf59ab
diff --git a/apps/web/lib/submitted-leads/create-partner-submitted-lead-comment-action.ts b/apps/web/lib/submitted-leads/create-partner-submitted-lead-comment-action.ts
index 2c01f95217..7c7a777a4f 100644
--- a/apps/web/lib/submitted-leads/create-partner-submitted-lead-comment-action.ts
+++ b/apps/web/lib/submitted-leads/create-partner-submitted-lead-comment-action.ts
@@ -2,10 +2,12 @@
import { DubApiError } from "@/lib/api/errors";
import { prisma } from "@/lib/prisma";
+import { enqueueSubmittedLeadCommentNotification } from "@/lib/submitted-leads/submitted-lead-comment-notifications";
import {
SubmittedLeadCommentSchema,
createPartnerSubmittedLeadCommentSchema,
} from "@/lib/zod/schemas/submitted-leads";
+import { waitUntil } from "@vercel/functions";
import { authPartnerActionClient } from "../actions/safe-action";
import { ACTIVE_ENROLLMENT_STATUSES } from "../zod/schemas/partners";
@@ -52,6 +54,14 @@ export const createPartnerSubmittedLeadCommentAction = authPartnerActionClient
},
});
+ waitUntil(
+ enqueueSubmittedLeadCommentNotification({
+ recipient: "program",
+ leadId: lead.id,
+ commentId: comment.id,
+ }),
+ );
+
return {
comment: SubmittedLeadCommentSchema.parse(comment),
};
diff --git a/apps/web/lib/submitted-leads/create-submitted-lead-comment-action.ts b/apps/web/lib/submitted-leads/create-submitted-lead-comment-action.ts
index bad42188d8..e5af464c4d 100644
--- a/apps/web/lib/submitted-leads/create-submitted-lead-comment-action.ts
+++ b/apps/web/lib/submitted-leads/create-submitted-lead-comment-action.ts
@@ -3,10 +3,12 @@
import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-program-id-or-throw";
import { prisma } from "@/lib/prisma";
import { getSubmittedLeadOrThrow } from "@/lib/submitted-leads/get-submitted-lead-or-throw";
+import { enqueueSubmittedLeadCommentNotification } from "@/lib/submitted-leads/submitted-lead-comment-notifications";
import {
SubmittedLeadCommentSchema,
createSubmittedLeadCommentSchema,
} from "@/lib/zod/schemas/submitted-leads";
+import { waitUntil } from "@vercel/functions";
import { authActionClient } from "../actions/safe-action";
import { throwIfNoPermission } from "../actions/throw-if-no-permission";
@@ -41,6 +43,16 @@ export const createSubmittedLeadCommentAction = authActionClient
},
});
+ if (partnerVisible) {
+ waitUntil(
+ enqueueSubmittedLeadCommentNotification({
+ recipient: "partner",
+ leadId: lead.id,
+ commentId: comment.id,
+ }),
+ );
+ }
+
return {
comment: SubmittedLeadCommentSchema.parse(comment),
};