Skip to content

Commit

Permalink
Merge pull request #607 from mfts/feat/user-overview
Browse files Browse the repository at this point in the history
feat(prisma): adjust viewer table model
  • Loading branch information
mfts authored Sep 21, 2024
2 parents 79229df + 90cc743 commit 0b45af8
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 31 deletions.
21 changes: 21 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ const nextConfig = {
},
];
},
async headers() {
return [
{
source: "/:path*",
headers: [
{
key: "Referrer-Policy",
value: "no-referrer-when-downgrade",
},
{
key: "X-DNS-Prefetch-Control",
value: "on",
},
{
key: "X-Frame-Options",
value: "DENY",
},
],
},
];
},
experimental: {
outputFileTracingIncludes: {
"/api/mupdf/*": ["./node_modules/mupdf/dist/*.wasm"],
Expand Down
6 changes: 3 additions & 3 deletions pages/api/jobs/send-dataroom-new-document-notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ export default async function handle(
senderUserId: string;
};

let viewer: { email: string; dataroom: { name: string } } | null = null;
let viewer: { email: string; dataroom: { name: string } | null } | null =
null;

try {
// Fetch the link to verify the settings
viewer = await prisma.viewer.findUnique({
where: {
id: viewerId,
dataroomId: dataroomId,
},
select: {
email: true,
Expand Down Expand Up @@ -98,7 +98,7 @@ export default async function handle(
}

await sendDataroomNotification({
dataroomName: viewer.dataroom.name,
dataroomName: viewer.dataroom?.name ?? "",
senderEmail: user.email!,
documentName: document?.document.name,
to: viewer.email,
Expand Down
6 changes: 3 additions & 3 deletions pages/api/jobs/send-dataroom-view-invitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ export default async function handle(
senderUserId: string;
};

let viewer: { email: string; dataroom: { name: string } } | null = null;
let viewer: { email: string; dataroom: { name: string } | null } | null =
null;

try {
// Fetch the link to verify the settings
viewer = await prisma.viewer.findUnique({
where: {
id: viewerId,
dataroomId: dataroomId,
},
select: {
email: true,
Expand Down Expand Up @@ -82,7 +82,7 @@ export default async function handle(

// send email to document owner that document
await sendDataroomViewerInvite({
dataroomName: viewer.dataroom.name,
dataroomName: viewer.dataroom?.name ?? "",
senderEmail: user.email!,
to: viewer.email,
url: `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${linkId}?email=${encodeURIComponent(viewer.email)}`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- DropForeignKey
ALTER TABLE "Viewer" DROP CONSTRAINT "Viewer_dataroomId_fkey";

-- DropIndex
DROP INDEX "Viewer_dataroomId_email_key";

-- AlterTable
ALTER TABLE "Viewer" ALTER COLUMN "dataroomId" DROP NOT NULL,
ALTER COLUMN "teamId" SET NOT NULL;

-- CreateIndex
CREATE UNIQUE INDEX "Viewer_teamId_email_key" ON "Viewer"("teamId", "email");

-- AddForeignKey
ALTER TABLE "Viewer" ADD CONSTRAINT "Viewer_dataroomId_fkey" FOREIGN KEY ("dataroomId") REFERENCES "Dataroom"("id") ON DELETE SET NULL ON UPDATE CASCADE;

50 changes: 25 additions & 25 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,27 @@ model VerificationToken {
}

model Document {
id String @id @default(cuid())
name String
description String?
file String // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)
originalFile String? // This should be a reference to the original file like pptx, xlsx, etc. (S3, Google Cloud Storage, etc.)
type String? // This should be a reference to the file type (pdf, sheet, etc.)
contentType String? // This should be the actual contentType of the file like application/pdf, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, etc.
storageType DocumentStorageType @default(VERCEL_BLOB)
numPages Int? // This should be a reference to the number of pages in the document
owner User? @relation(fields: [ownerId], references: [id], onDelete: SetNull)
teamId String
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
ownerId String? // This field holds the foreign key.
assistantEnabled Boolean @default(false) // This indicates if assistant is enabled for this document
id String @id @default(cuid())
name String
description String?
file String // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)
originalFile String? // This should be a reference to the original file like pptx, xlsx, etc. (S3, Google Cloud Storage, etc.)
type String? // This should be a reference to the file type (pdf, sheet, etc.)
contentType String? // This should be the actual contentType of the file like application/pdf, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, etc.
storageType DocumentStorageType @default(VERCEL_BLOB)
numPages Int? // This should be a reference to the number of pages in the document
owner User? @relation(fields: [ownerId], references: [id], onDelete: SetNull)
teamId String
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
ownerId String? // This field holds the foreign key.
assistantEnabled Boolean @default(false) // This indicates if assistant is enabled for this document
advancedExcelEnabled Boolean @default(false) // This indicates if advanced Excel is enabled for this document
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
links Link[]
views View[]
versions DocumentVersion[]
conversations Conversation[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
links Link[]
views View[]
versions DocumentVersion[]
conversations Conversation[]
folderId String? // Optional Folder ID for documents in folders
folder Folder? @relation(fields: [folderId], references: [id], onDelete: SetNull)
Expand Down Expand Up @@ -339,18 +339,18 @@ model Viewer {
verified Boolean @default(false) // Whether the viewer email has been verified
invitedAt DateTime? // This is the time the viewer was invited
dataroomId String
dataroom Dataroom @relation(fields: [dataroomId], references: [id], onDelete: Cascade)
teamId String?
team Team? @relation(fields: [teamId], references: [id], onDelete: Cascade)
dataroomId String?
dataroom Dataroom? @relation(fields: [dataroomId], references: [id], onDelete: SetNull)
teamId String
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
views View[]
groups ViewerGroupMembership[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([dataroomId, email])
@@unique([teamId, email])
@@index([teamId])
@@index([dataroomId])
}
Expand Down

0 comments on commit 0b45af8

Please sign in to comment.