urls are now editable

This commit is contained in:
daniel31x13
2024-09-12 15:03:14 -04:00
parent 7bd3872195
commit 8bb6e32bfa
3 changed files with 67 additions and 43 deletions
+14 -18
View File
@@ -54,7 +54,20 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
response: "Invalid URL.",
});
await deleteArchivedFiles(link);
await prisma.link.update({
where: {
id: link.id,
},
data: {
image: null,
pdf: null,
readable: null,
monolith: null,
preview: null,
},
});
await removeFiles(link.id, link.collection.id);
return res.status(200).json({
response: "Link is being archived.",
@@ -72,20 +85,3 @@ const getTimezoneDifferenceInMinutes = (future: Date, past: Date) => {
return diffInMinutes;
};
const deleteArchivedFiles = async (link: Link & { collection: Collection }) => {
await prisma.link.update({
where: {
id: link.id,
},
data: {
image: null,
pdf: null,
readable: null,
monolith: null,
preview: null,
},
});
await removeFiles(link.id, link.collection.id);
};