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 staging member sync after invite verification

Kiran Kef396d3004dd
diff --git a/apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsx b/apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsx
index 9852954136..863687b745 100644
--- a/apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsx
+++ b/apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsx
@@ -1,11 +1,13 @@
import { onboardingStepCache } from "@/lib/api/workspaces/onboarding-step-cache";
import { getSession } from "@/lib/auth";
+import { addMemberToStaging } from "@/lib/sandbox/sync-member-to-staging";
import EmptyState from "@/ui/shared/empty-state";
import { prisma } from "@dub/prisma";
import { LoadingSpinner } from "@dub/ui";
import { LinkBroken, Users6 } from "@dub/ui/icons";
import { APP_NAME } from "@dub/utils";
import { redirect } from "next/navigation";
+import { after } from "next/server";
import { Suspense } from "react";
export default async function InvitesPage(props: {
@@ -46,6 +48,7 @@ async function VerifyInvite({ code }: { code: string }) {
id: true,
slug: true,
usersLimit: true,
+ stagingWorkspaceId: true,
users: {
where: {
userId: session.user.id,
@@ -93,12 +96,12 @@ async function VerifyInvite({ code }: { code: string }) {
);
}
- await prisma.projectUsers.create({
+ const workspaceUser = await prisma.projectUsers.create({
data: {
userId: session.user.id,
projectId: workspace.id,
notificationPreference: {
- create: {}, // by default, users are opted in to all notifications
+ create: {},
},
},
});
@@ -115,6 +118,16 @@ async function VerifyInvite({ code }: { code: string }) {
});
}
+ after(
+ addMemberToStaging({
+ workspace,
+ user: {
+ id: workspaceUser.userId,
+ role: workspaceUser.role,
+ },
+ }),
+ );
+
// Complete onboarding just in case
await onboardingStepCache.set({
userId: session.user.id,