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 partner notification preference

Tim Wilson248d389afc8a
diff --git a/apps/web/app/(ee)/api/cron/messages/notify-partner/route.ts b/apps/web/app/(ee)/api/cron/messages/notify-partner/route.ts
index 34eda90e7a..f1f7c57bce 100644
--- a/apps/web/app/(ee)/api/cron/messages/notify-partner/route.ts
+++ b/apps/web/app/(ee)/api/cron/messages/notify-partner/route.ts
@@ -64,6 +64,11 @@ export async function POST(req: Request) {
include: {
user: true,
},
+ where: {
+ notificationPreferences: {
+ newMessageFromProgram: true,
+ },
+ },
},
},
},
diff --git a/apps/web/app/(ee)/api/partner-profile/notification-preferences/route.ts b/apps/web/app/(ee)/api/partner-profile/notification-preferences/route.ts
index 7e4bd7bb32..6d966adbdb 100644
--- a/apps/web/app/(ee)/api/partner-profile/notification-preferences/route.ts
+++ b/apps/web/app/(ee)/api/partner-profile/notification-preferences/route.ts
@@ -15,6 +15,7 @@ export const GET = withPartnerProfile(async ({ partner, session }) => {
select: {
commissionCreated: true,
applicationApproved: true,
+ newMessageFromProgram: true,
},
},
);
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/account/settings/notifications/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/account/settings/notifications/page-client.tsx
index 533b596a17..7d83dd54f3 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/account/settings/notifications/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/account/settings/notifications/page-client.tsx
@@ -5,6 +5,7 @@ import { partnerNotificationTypes } from "@/lib/zod/schemas/partner-profile";
import {
CircleCheck,
InvoiceDollar,
+ Msgs,
Switch,
useOptimisticUpdate,
} from "@dub/ui";
@@ -27,6 +28,12 @@ const notifications = [
title: "Application approval",
description: "Alert when an application to a program is approved.",
},
+ {
+ type: "newMessageFromProgram",
+ icon: Msgs,
+ title: "New message from program",
+ description: "Alert when a new message is received from a program.",
+ },
] as const;
export function PartnerSettingsNotificationsPageClient() {
diff --git a/apps/web/lib/zod/schemas/partner-profile.ts b/apps/web/lib/zod/schemas/partner-profile.ts
index 3b8ba4210b..d31fa3d381 100644
--- a/apps/web/lib/zod/schemas/partner-profile.ts
+++ b/apps/web/lib/zod/schemas/partner-profile.ts
@@ -132,6 +132,7 @@ export const partnerProfileProgramsCountQuerySchema =
export const partnerNotificationTypes = z.enum([
"commissionCreated",
"applicationApproved",
+ "newMessageFromProgram",
]);
export const PartnerBountySchema = BountySchema.omit({
diff --git a/packages/prisma/schema/partner.prisma b/packages/prisma/schema/partner.prisma
index 09298c3eb4..353ba17465 100644
--- a/packages/prisma/schema/partner.prisma
+++ b/packages/prisma/schema/partner.prisma
@@ -94,8 +94,9 @@ model PartnerNotificationPreferences {
id String @id @default(cuid())
partnerUserId String @unique
- commissionCreated Boolean @default(true)
- applicationApproved Boolean @default(true)
+ commissionCreated Boolean @default(true)
+ applicationApproved Boolean @default(true)
+ newMessageFromProgram Boolean @default(true)
partnerUser PartnerUser @relation(fields: [partnerUserId], references: [id], onDelete: Cascade)
}