diff --git a/components/LinkCard.tsx b/components/LinkCard.tsx
index 0d49d7b..9140216 100644
--- a/components/LinkCard.tsx
+++ b/components/LinkCard.tsx
@@ -155,9 +155,7 @@ export default function LinkCard({ link, count, className }: Props) {
{profileStatus && (
diff --git a/lib/api/controllers/links/postLink.ts b/lib/api/controllers/links/postLink.ts
index 85cbe46..6d07932 100644
--- a/lib/api/controllers/links/postLink.ts
+++ b/lib/api/controllers/links/postLink.ts
@@ -3,7 +3,6 @@ import { LinkIncludingCollectionAndTags } from "@/types/global";
import getTitle from "../../getTitle";
import archive from "../../archive";
import { Link, UsersAndCollections } from "@prisma/client";
-import AES from "crypto-js/aes";
import getPermission from "@/lib/api/getPermission";
import { existsSync, mkdirSync } from "fs";
@@ -77,31 +76,14 @@ export default async function postLink(
screenshotPath: "",
pdfPath: "",
},
- });
-
- const AES_SECRET = process.env.AES_SECRET as string;
-
- const screenshotHashedPath = AES.encrypt(
- `data/archives/${newLink.collectionId}/${newLink.id}.png`,
- AES_SECRET
- ).toString();
-
- const pdfHashedPath = AES.encrypt(
- `data/archives/${newLink.collectionId}/${newLink.id}.pdf`,
- AES_SECRET
- ).toString();
-
- const updatedLink = await prisma.link.update({
- where: { id: newLink.id },
- data: { screenshotPath: screenshotHashedPath, pdfPath: pdfHashedPath },
include: { tags: true, collection: true },
});
- const collectionPath = `data/archives/${updatedLink.collection.id}`;
+ const collectionPath = `data/archives/${newLink.collectionId}`;
if (!existsSync(collectionPath))
mkdirSync(collectionPath, { recursive: true });
- archive(updatedLink.url, updatedLink.collectionId, updatedLink.id);
+ archive(newLink.url, newLink.collectionId, newLink.id);
- return { response: updatedLink, status: 200 };
+ return { response: newLink, status: 200 };
}
diff --git a/pages/api/archives/[...params].ts b/pages/api/archives/[...params].ts
index 3a2c2a0..cae7425 100644
--- a/pages/api/archives/[...params].ts
+++ b/pages/api/archives/[...params].ts
@@ -1,8 +1,6 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { getServerSession } from "next-auth/next";
import { authOptions } from "pages/api/auth/[...nextauth]";
-import AES from "crypto-js/aes";
-import enc from "crypto-js/enc-utf8";
import path from "path";
import fs from "fs";
import getPermission from "@/lib/api/getPermission";
@@ -12,6 +10,7 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
return res.status(401).json({ response: "Invalid parameters." });
const collectionId = req.query.params[0];
+ const linkId = req.query.params[1];
const session = await getServerSession(req, res, authOptions);
@@ -28,11 +27,10 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
.status(401)
.json({ response: "You don't have access to this collection." });
- const AES_SECRET = process.env.AES_SECRET as string;
- const encryptedPath = decodeURIComponent(req.query.params[1]) as string;
- const decryptedPath = AES.decrypt(encryptedPath, AES_SECRET).toString(enc);
+ const requestedPath = `data/archives/${collectionId}/${linkId}`;
+
+ const filePath = path.join(process.cwd(), requestedPath);
- const filePath = path.join(process.cwd(), decryptedPath);
const file = fs.existsSync(filePath)
? fs.readFileSync(filePath)
: "File not found, it's possible that the file you're looking for either doesn't exist or hasn't been created yet.";
diff --git a/prisma/migrations/20230612181740_init/migration.sql b/prisma/migrations/20230613142801_init/migration.sql
similarity index 98%
rename from prisma/migrations/20230612181740_init/migration.sql
rename to prisma/migrations/20230613142801_init/migration.sql
index 602ce21..8f5a1af 100644
--- a/prisma/migrations/20230612181740_init/migration.sql
+++ b/prisma/migrations/20230613142801_init/migration.sql
@@ -69,8 +69,6 @@ CREATE TABLE "Link" (
"url" TEXT NOT NULL,
"title" TEXT NOT NULL,
"collectionId" INTEGER NOT NULL,
- "screenshotPath" TEXT NOT NULL,
- "pdfPath" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Link_pkey" PRIMARY KEY ("id")
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index b3bf3b6..37503c7 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -93,8 +93,6 @@ model Link {
collectionId Int
tags Tag[]
pins PinnedLinks[]
- screenshotPath String
- pdfPath String
createdAt DateTime @default(now())
}