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.

Add 'newBountySubmitted' notification preference

Kiran Kb68354f56a25
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/notification-preferences/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/notification-preferences/route.ts
index 168bf59da0..cfac050216 100644
--- a/apps/web/app/api/workspaces/[idOrSlug]/notification-preferences/route.ts
+++ b/apps/web/app/api/workspaces/[idOrSlug]/notification-preferences/route.ts
@@ -10,6 +10,7 @@ export const GET = withWorkspace(async ({ workspace, session }) => {
linkUsageSummary: true,
newPartnerSale: true,
newPartnerApplication: true,
+ newBountySubmitted: true,
},
where: {
projectUser: {
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/(basic-layout)/notifications/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/(basic-layout)/notifications/page-client.tsx
index 508cbb730f..8f9f077f0a 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/(basic-layout)/notifications/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/(basic-layout)/notifications/page-client.tsx
@@ -5,7 +5,7 @@ import useWorkspace from "@/lib/swr/use-workspace";
import { notificationTypes } from "@/lib/zod/schemas/workspaces";
import { Switch, useOptimisticUpdate } from "@dub/ui";
import { Globe, Hyperlink, UserPlus } from "@dub/ui/icons";
-import { DollarSign } from "lucide-react";
+import { DollarSign, Trophy } from "lucide-react";
import { useAction } from "next-safe-action/hooks";
import { z } from "zod";
@@ -43,6 +43,13 @@ export default function NotificationsSettingsPageClient() {
title: "New partner sale",
description: "Alert when a new sale is made in your partner program.",
},
+ {
+ type: "newBountySubmitted",
+ icon: Trophy,
+ title: "New bounty submitted",
+ description:
+ "Alert when a new bounty is submitted in your partner program.",
+ },
];
const {
diff --git a/apps/web/lib/actions/partners/create-bounty-submission.ts b/apps/web/lib/actions/partners/create-bounty-submission.ts
index ee35264a4c..4ef93f5f9f 100644
--- a/apps/web/lib/actions/partners/create-bounty-submission.ts
+++ b/apps/web/lib/actions/partners/create-bounty-submission.ts
@@ -130,6 +130,7 @@ export const createBountySubmissionAction = authPartnerActionClient
const { users, program, ...workspace } = await getWorkspaceUsers({
programId,
role: Role.owner,
+ notificationPreference: "newBountySubmitted",
});
if (users.length > 0) {
diff --git a/apps/web/lib/api/get-workspace-users.ts b/apps/web/lib/api/get-workspace-users.ts
index ac77860aeb..f46e99576f 100644
--- a/apps/web/lib/api/get-workspace-users.ts
+++ b/apps/web/lib/api/get-workspace-users.ts
@@ -1,18 +1,20 @@
import { prisma } from "@dub/prisma";
-import { NotificationPreference, Role } from "@prisma/client";
+import { Role } from "@prisma/client";
+import { z } from "zod";
+import { notificationTypes } from "../zod/schemas/workspaces";
type GetWorkspaceUsersParams =
| {
workspaceId: string;
programId?: never;
role: Role;
- notificationPreference?: NotificationPreference;
+ notificationPreference?: z.infer<typeof notificationTypes>;
}
| {
programId: string;
workspaceId?: never;
role: Role;
- notificationPreference?: NotificationPreference;
+ notificationPreference?: z.infer<typeof notificationTypes>;
};
export async function getWorkspaceUsers({
@@ -49,7 +51,11 @@ export async function getWorkspaceUsers({
users: {
where: {
role,
- ...(notificationPreference && { notificationPreference }),
+ ...(notificationPreference && {
+ notificationPreference: {
+ [notificationPreference]: true,
+ },
+ }),
},
select: {
user: {
diff --git a/apps/web/lib/zod/schemas/workspaces.ts b/apps/web/lib/zod/schemas/workspaces.ts
index 22f128cf71..028b60d271 100644
--- a/apps/web/lib/zod/schemas/workspaces.ts
+++ b/apps/web/lib/zod/schemas/workspaces.ts
@@ -165,6 +165,7 @@ export const notificationTypes = z.enum([
"domainConfigurationUpdates",
"newPartnerSale",
"newPartnerApplication",
+ "newBountySubmitted",
]);
export const WorkspaceSchemaExtended = WorkspaceSchema.extend({
diff --git a/packages/prisma/schema/workspace.prisma b/packages/prisma/schema/workspace.prisma
index aecd9d58f9..3fa563e80d 100644
--- a/packages/prisma/schema/workspace.prisma
+++ b/packages/prisma/schema/workspace.prisma
@@ -126,6 +126,7 @@ model NotificationPreference {
domainConfigurationUpdates Boolean @default(true)
newPartnerSale Boolean @default(true)
newPartnerApplication Boolean @default(true)
+ newBountySubmitted Boolean @default(true)
projectUser ProjectUsers @relation(fields: [projectUserId], references: [id], onDelete: Cascade)
}