final touch

This commit is contained in:
daniel31x13
2024-03-05 09:03:04 -05:00
parent 750aa294d0
commit f26cd31694
5 changed files with 24 additions and 23 deletions
+14 -13
View File
@@ -93,20 +93,21 @@ export default async function postLink(
},
});
const existingLink = await prisma.link.findFirst({
where: {
url: link.url,
collection: {
ownerId: userId,
if (user?.preventDuplicateLinks) {
const existingLink = await prisma.link.findFirst({
where: {
url: link.url?.trim(),
collection: {
ownerId: userId,
},
},
},
});
});
if (existingLink && user?.mergeDuplicateLinks) {
return {
response: "Link already exists",
status: 409,
};
if (existingLink)
return {
response: "Link already exists",
status: 409,
};
}
const numberOfLinksTheUserHas = await prisma.link.count({
@@ -148,7 +149,7 @@ export default async function postLink(
const newLink = await prisma.link.create({
data: {
url: link.url,
url: link.url?.trim(),
name: link.name,
description,
type: linkType,