Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
team scoped api/domain/index.ts
Aashish-Upadhyay-10155aa68dcc880
diff --git a/lib/team/helper.ts b/lib/team/helper.tsindex abf46294..96acdaaf 100644--- a/lib/team/helper.ts+++ b/lib/team/helper.ts@@ -9,6 +9,12 @@ interface ITeamUserAndDocument {options?: {};}+interface ITeamWithDomain {+ teamId: string;+ userId: string;+ options?: {};+}+export async function getTeamWithUsersAndDocument({teamId,userId,@@ -62,3 +68,38 @@ export async function getTeamWithUsersAndDocument({return { team, document };}++export async function getTeamWithDomain({+ teamId,+ userId,+ options,+}: ITeamWithDomain) {+ const team = await prisma.team.findUnique({+ where: {+ id: teamId,+ },+ include: {+ users: {+ select: {+ userId: true,+ },+ },+ domains: {+ ...options,+ },+ },+ });++ // check if the team exists+ if (!team) {+ throw new TeamError("Team doesn't exists");+ }++ // check if the user is part the team+ const teamHasUser = team?.users.some((user) => user.userId === userId);+ if (!teamHasUser) {+ throw new TeamError("You are not a member of the team");+ }++ return { team };+}