ui improvements
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { prisma } from "@/lib/api/db";
|
||||
import { Session } from "next-auth";
|
||||
import { ExtendedLink, NewLink } from "@/types/global";
|
||||
import { existsSync, mkdirSync } from "fs";
|
||||
import getTitle from "../../getTitle";
|
||||
import archive from "../../archive";
|
||||
import { ExtendedLink } from "@/types/global";
|
||||
import fs from "fs";
|
||||
import { Link, UsersAndCollections } from "@prisma/client";
|
||||
import AES from "crypto-js/aes";
|
||||
import hasAccessToCollection from "@/lib/api/hasAccessToCollection";
|
||||
|
||||
export default async function (
|
||||
@@ -42,6 +39,14 @@ export default async function (
|
||||
},
|
||||
});
|
||||
|
||||
fs.unlink(`data/archives/${link.collectionId}/${link.id}.pdf`, (err) => {
|
||||
if (err) console.log(err);
|
||||
});
|
||||
|
||||
fs.unlink(`data/archives/${link.collectionId}/${link.id}.png`, (err) => {
|
||||
if (err) console.log(err);
|
||||
});
|
||||
|
||||
return res.status(200).json({
|
||||
response: deleteLink,
|
||||
});
|
||||
|
||||
@@ -118,7 +118,7 @@ export default async function (
|
||||
|
||||
const AES_SECRET = process.env.AES_SECRET as string;
|
||||
|
||||
const screenShotHashedPath = AES.encrypt(
|
||||
const screenshotHashedPath = AES.encrypt(
|
||||
`data/archives/${newLink.collectionId}/${newLink.id}.png`,
|
||||
AES_SECRET
|
||||
).toString();
|
||||
@@ -130,7 +130,7 @@ export default async function (
|
||||
|
||||
const updatedLink: ExtendedLink = await prisma.link.update({
|
||||
where: { id: newLink.id },
|
||||
data: { screenshotPath: screenShotHashedPath, pdfPath: pdfHashedPath },
|
||||
data: { screenshotPath: screenshotHashedPath, pdfPath: pdfHashedPath },
|
||||
include: { tags: true, collection: true },
|
||||
});
|
||||
|
||||
|
||||
@@ -7,6 +7,15 @@ export default async function (
|
||||
res: NextApiResponse,
|
||||
session: Session
|
||||
) {
|
||||
// tag cleanup
|
||||
await prisma.tag.deleteMany({
|
||||
where: {
|
||||
links: {
|
||||
none: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const tags = await prisma.tag.findMany({
|
||||
where: {
|
||||
collections: {
|
||||
|
||||
Reference in New Issue
Block a user