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.

bounty approved email

Kiran K6bee6bb91310
diff --git a/apps/web/lib/actions/partners/approve-bounty-submission.ts b/apps/web/lib/actions/partners/approve-bounty-submission.ts
index 4a5f85dff0..f27da87120 100644
--- a/apps/web/lib/actions/partners/approve-bounty-submission.ts
+++ b/apps/web/lib/actions/partners/approve-bounty-submission.ts
@@ -2,7 +2,10 @@
import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-program-id-or-throw";
import { createPartnerCommission } from "@/lib/partners/create-partner-commission";
+import { sendEmail } from "@dub/email";
+import BountyApproved from "@dub/email/templates/bounty-approved";
import { prisma } from "@dub/prisma";
+import { waitUntil } from "@vercel/functions";
import { z } from "zod";
import { authActionClient } from "../safe-action";
@@ -20,18 +23,17 @@ export const approveBountySubmissionAction = authActionClient
const programId = getDefaultProgramIdOrThrow(workspace);
- const bountySubmission = await prisma.bountySubmission.findUnique({
- where: {
- id: submissionId,
- },
- include: {
- bounty: true,
- },
- });
-
- if (!bountySubmission) {
- throw new Error("Bounty submission not found.");
- }
+ const { program, bounty, partner, ...bountySubmission } =
+ await prisma.bountySubmission.findUniqueOrThrow({
+ where: {
+ id: submissionId,
+ },
+ include: {
+ program: true,
+ bounty: true,
+ partner: true,
+ },
+ });
if (bountySubmission.programId !== programId) {
throw new Error("Bounty submission does not belong to this program.");
@@ -41,8 +43,6 @@ export const approveBountySubmissionAction = authActionClient
throw new Error("Bounty submission already approved.");
}
- const { bounty } = bountySubmission;
-
if (bounty.type === "performance") {
throw new Error("Performance based bounties cannot be approved.");
}
@@ -75,6 +75,28 @@ export const approveBountySubmissionAction = authActionClient
},
});
+ if (partner.email) {
+ waitUntil(
+ sendEmail({
+ subject: "Bounty approved!",
+ email: partner.email,
+ variant: "notifications",
+ react: BountyApproved({
+ email: partner.email,
+ program: {
+ name: program.name,
+ slug: program.slug,
+ supportEmail: program.supportEmail || "[email protected]",
+ },
+ bounty: {
+ name: bounty.name!,
+ type: bounty.type,
+ },
+ }),
+ }),
+ );
+ }
+
// TODO:
// Record audit log
});
diff --git a/packages/email/src/templates/bounty-approved.tsx b/packages/email/src/templates/bounty-approved.tsx
index 1fd977a979..72a0bb4816 100644
--- a/packages/email/src/templates/bounty-approved.tsx
+++ b/packages/email/src/templates/bounty-approved.tsx
@@ -16,26 +16,26 @@ import { BountyThumbnailImage } from "src/components/bounty-thumbnail";
import { Footer } from "../components/footer";
export default function BountyApproved({
- bounty = {
- name: "Promote Acme at your campus and earn $500 ",
- type: "performance",
- },
program = {
name: "Acme",
slug: "acme",
supportEmail: "[email protected]",
},
+ bounty = {
+ name: "Promote Acme at your campus and earn $500 ",
+ type: "performance",
+ },
email = "[email protected]",
}: {
- bounty: {
- name: string;
- type: "performance" | "submission";
- };
program: {
slug: string;
name: string;
supportEmail: string;
};
+ bounty: {
+ name: string;
+ type: "performance" | "submission";
+ };
email: string;
}) {
return (