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.

Remove the folder request

Kiran K719e9b0ee9dd
diff --git a/apps/web/lib/actions/folders/update-folder-user-role.ts b/apps/web/lib/actions/folders/update-folder-user-role.ts
index 1b39ade617..cdb44e99cc 100644
--- a/apps/web/lib/actions/folders/update-folder-user-role.ts
+++ b/apps/web/lib/actions/folders/update-folder-user-role.ts
@@ -1,6 +1,7 @@
"use server";
import { prisma } from "@dub/prisma";
+import { waitUntil } from "@vercel/functions";
import { z } from "zod";
import { verifyFolderAccess } from "../../folder/permissions";
import { folderUserRoleSchema } from "../../zod/schemas/folders";
@@ -48,6 +49,22 @@ export const updateUserRoleInFolder = authActionClient
},
});
- // TODO:
- // Remove the folder request if the user has a pending request
+ waitUntil(
+ (async () => {
+ try {
+ await prisma.folderAccessRequest.delete({
+ where: {
+ folderId_userId: {
+ folderId,
+ userId,
+ },
+ },
+ });
+ } catch (error) {
+ if (error.code !== "P2025") {
+ console.error("Error deleting folder access request", error);
+ }
+ }
+ })(),
+ );
});