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 rejected email

Kiran Kc6f9842bd0f6
diff --git a/apps/web/lib/actions/partners/reject-bounty-submission.ts b/apps/web/lib/actions/partners/reject-bounty-submission.ts
index 991e563b37..ec3d66fe6b 100644
--- a/apps/web/lib/actions/partners/reject-bounty-submission.ts
+++ b/apps/web/lib/actions/partners/reject-bounty-submission.ts
@@ -1,8 +1,14 @@
"use server";
import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-program-id-or-throw";
-import { rejectBountySubmissionSchema } from "@/lib/zod/schemas/bounties";
+import {
+ REJECT_BOUNTY_SUBMISSION_REASONS,
+ rejectBountySubmissionSchema,
+} from "@/lib/zod/schemas/bounties";
+import { sendEmail } from "@dub/email";
+import BountyRejected from "@dub/email/templates/bounty-rejected";
import { prisma } from "@dub/prisma";
+import { waitUntil } from "@vercel/functions";
import { authActionClient } from "../safe-action";
// Reject a bounty submission
@@ -14,11 +20,17 @@ export const rejectBountySubmissionAction = authActionClient
const programId = getDefaultProgramIdOrThrow(workspace);
- const bountySubmission = await prisma.bountySubmission.findUniqueOrThrow({
- where: {
- id: submissionId,
- },
- });
+ 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.");
@@ -56,6 +68,31 @@ export const rejectBountySubmissionAction = authActionClient
}
});
+ if (partner.email) {
+ waitUntil(
+ sendEmail({
+ subject: "Bounty rejected",
+ email: partner.email,
+ variant: "notifications",
+ react: BountyRejected({
+ email: partner.email,
+ program: {
+ name: program.name,
+ slug: program.slug,
+ supportEmail: program.supportEmail || "[email protected]",
+ },
+ bounty: {
+ name: bounty.name!,
+ },
+ submission: {
+ rejectionReason:
+ REJECT_BOUNTY_SUBMISSION_REASONS[rejectionReason],
+ },
+ }),
+ }),
+ );
+ }
+
// TODO:
// Record audit log
});
diff --git a/packages/email/src/templates/bounty-rejected.tsx b/packages/email/src/templates/bounty-rejected.tsx
index e1843005a1..4596fe2b60 100644
--- a/packages/email/src/templates/bounty-rejected.tsx
+++ b/packages/email/src/templates/bounty-rejected.tsx
@@ -15,27 +15,27 @@ import {
import { Footer } from "../components/footer";
export default function BountyRejected({
- bounty = {
- name: "Promote Acme at your campus and earn $500 ",
- },
program = {
name: "Acme",
slug: "acme",
supportEmail: "[email protected]",
},
+ bounty = {
+ name: "Promote Acme at your campus and earn $500 ",
+ },
submission = {
rejectionReason: "Not a valid URL",
},
email = "[email protected]",
}: {
- bounty: {
- name: string;
- };
program: {
slug: string;
name: string;
supportEmail: string;
};
+ bounty: {
+ name: string;
+ };
submission: {
rejectionReason: string;
};