+
{children}
diff --git a/lib/api/checkSubscription.ts b/lib/api/checkSubscription.ts
index 6537c22..b459fb3 100644
--- a/lib/api/checkSubscription.ts
+++ b/lib/api/checkSubscription.ts
@@ -2,8 +2,7 @@ import Stripe from "stripe";
export default async function checkSubscription(
stripeSecretKey: string,
- email: string,
- priceId: string
+ email: string
) {
const stripe = new Stripe(stripeSecretKey, {
apiVersion: "2022-11-15",
@@ -33,11 +32,7 @@ export default async function checkSubscription(
new Date((subscription.canceled_at + secondsInTwoWeeks) * 1000)
);
- return (
- subscription?.items?.data?.some(
- (subscriptionItem) => subscriptionItem?.plan?.id === priceId
- ) && isNotCanceledOrHasTime
- );
+ return subscription?.items?.data[0].plan && isNotCanceledOrHasTime;
}
);
diff --git a/lib/api/controllers/links/getLinks.ts b/lib/api/controllers/links/getLinks.ts
index e61f2a1..be02293 100644
--- a/lib/api/controllers/links/getLinks.ts
+++ b/lib/api/controllers/links/getLinks.ts
@@ -26,11 +26,11 @@ export default async function getLink(userId: number, body: string) {
};
else if (query.sort === Sort.DescriptionAZ)
order = {
- name: "asc",
+ description: "asc",
};
else if (query.sort === Sort.DescriptionZA)
order = {
- name: "desc",
+ description: "desc",
};
const links = await prisma.link.findMany({
diff --git a/lib/api/controllers/links/postLink.ts b/lib/api/controllers/links/postLink.ts
index 66d8e91..8c849bb 100644
--- a/lib/api/controllers/links/postLink.ts
+++ b/lib/api/controllers/links/postLink.ts
@@ -21,7 +21,7 @@ export default async function postLink(
}
if (!link.collection.name) {
- link.collection.name = "Unnamed Collection";
+ link.collection.name = "Unorganized";
}
link.collection.name = link.collection.name.trim();
diff --git a/lib/api/controllers/links/updateLink.ts b/lib/api/controllers/links/updateLink.ts
index 24836c1..87954e1 100644
--- a/lib/api/controllers/links/updateLink.ts
+++ b/lib/api/controllers/links/updateLink.ts
@@ -32,11 +32,15 @@ export default async function updateLink(
const isCollectionOwner =
targetLink?.collection.ownerId === link.collection.ownerId &&
- link.collection.ownerId === userId &&
- targetLink?.collection.ownerId === userId;
+ link.collection.ownerId === userId;
+
+ const unauthorizedSwitchCollection =
+ !isCollectionOwner && targetLink?.collection.id !== link.collection.id;
+
+ console.log(isCollectionOwner);
// Makes sure collection members (non-owners) cannot move a link to/from a collection.
- if (!isCollectionOwner)
+ if (unauthorizedSwitchCollection)
return {
response: "You can't move a link to/from a collection you don't own.",
status: 401,
@@ -54,15 +58,11 @@ export default async function updateLink(
data: {
name: link.name,
description: link.description,
- collection:
- targetLink?.collection.ownerId === link.collection.ownerId &&
- link.collection.ownerId === userId
- ? {
- connect: {
- id: link.collection.id,
- },
- }
- : undefined,
+ collection: {
+ connect: {
+ id: link.collection.id,
+ },
+ },
tags: {
set: [],
connectOrCreate: link.tags.map((tag) => ({
@@ -99,14 +99,14 @@ export default async function updateLink(
},
});
- if (targetLink.collection.id !== link.collection.id) {
+ if (targetLink?.collection.id !== link.collection.id) {
await moveFile(
- `archives/${targetLink.collection.id}/${link.id}.pdf`,
+ `archives/${targetLink?.collection.id}/${link.id}.pdf`,
`archives/${link.collection.id}/${link.id}.pdf`
);
await moveFile(
- `archives/${targetLink.collection.id}/${link.id}.png`,
+ `archives/${targetLink?.collection.id}/${link.id}.png`,
`archives/${link.collection.id}/${link.id}.png`
);
}
diff --git a/lib/api/controllers/users/updateUser.ts b/lib/api/controllers/users/updateUser.ts
index f953557..5e1d0da 100644
--- a/lib/api/controllers/users/updateUser.ts
+++ b/lib/api/controllers/users/updateUser.ts
@@ -160,12 +160,10 @@ export default async function updateUser(
}
const STRIPE_SECRET_KEY = process.env.STRIPE_SECRET_KEY;
- const PRICE_ID = process.env.PRICE_ID;
- if (STRIPE_SECRET_KEY && PRICE_ID && emailEnabled)
+ if (STRIPE_SECRET_KEY && emailEnabled)
await updateCustomerEmail(
STRIPE_SECRET_KEY,
- PRICE_ID,
sessionUser.email,
user.email as string
);
diff --git a/lib/api/paymentCheckout.ts b/lib/api/paymentCheckout.ts
index 06dd7e3..49bf027 100644
--- a/lib/api/paymentCheckout.ts
+++ b/lib/api/paymentCheckout.ts
@@ -1,5 +1,4 @@
import Stripe from "stripe";
-import checkSubscription from "./checkSubscription";
export default async function paymentCheckout(
stripeSecretKey: string,
diff --git a/lib/api/storage/readFile.ts b/lib/api/storage/readFile.ts
index 57dd950..0721d9d 100644
--- a/lib/api/storage/readFile.ts
+++ b/lib/api/storage/readFile.ts
@@ -125,7 +125,7 @@ const fileNotFoundTemplate = `
It is possible that the file you're looking for either doesn't exist or hasn't been created yet.
Some possible reasons are:
- - You are trying to access a file too early, before it has been fully archived.
+ - You are trying to access a file too early, before it has been fully archived. If that's the case, refreshing the page might resolve the issue.
- The file doesn't exist either because it encountered an error while being archived, or it simply doesn't exist.