Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a886437589 | |||
| 8e6f88d29f | |||
| a82c4ef85f | |||
| 6983e41576 | |||
| 7e96ba63df | |||
| 7036b46084 | |||
| af7f0fb47c | |||
| 2bba8198b8 | |||
| 9d8ae6970c | |||
| 96a70a9689 | |||
| 6cae2fb634 | |||
| 288fd9df87 | |||
| 5e6d46b6b9 | |||
| a76e996fc1 | |||
| 2264abd384 | |||
| 6544e3ecbb | |||
| a8ffbc87d1 | |||
| 92c7f40956 | |||
| 6c29d905d9 | |||
| 9b85a2b1bb | |||
| cebe746ca7 | |||
| 5b0297bfe0 | |||
| 9c5226ee51 | |||
| 6d30912812 | |||
| 78111f010b | |||
| a2637d4526 | |||
| 479995366a | |||
| 7edd7f893b | |||
| 0185ec57c7 | |||
| 7c95761990 | |||
| c67526e54c | |||
| 8db5307747 | |||
| 54beb50576 | |||
| 9ab01da369 | |||
| 7e98de6122 | |||
| 5f34f03355 | |||
| 4344183564 | |||
| bc3ec3cc54 | |||
| fc97735703 | |||
| 8f38c82ed7 | |||
| 74030b26c5 |
+21
-5
@@ -21,7 +21,10 @@ BROWSER_TIMEOUT=
|
|||||||
IGNORE_UNAUTHORIZED_CA=
|
IGNORE_UNAUTHORIZED_CA=
|
||||||
IGNORE_HTTPS_ERRORS=
|
IGNORE_HTTPS_ERRORS=
|
||||||
IGNORE_URL_SIZE_LIMIT=
|
IGNORE_URL_SIZE_LIMIT=
|
||||||
ADMINISTRATOR=
|
NEXT_PUBLIC_DEMO=
|
||||||
|
NEXT_PUBLIC_DEMO_USERNAME=
|
||||||
|
NEXT_PUBLIC_DEMO_PASSWORD=
|
||||||
|
NEXT_PUBLIC_ADMIN=
|
||||||
NEXT_PUBLIC_MAX_FILE_BUFFER=
|
NEXT_PUBLIC_MAX_FILE_BUFFER=
|
||||||
MONOLITH_MAX_BUFFER=
|
MONOLITH_MAX_BUFFER=
|
||||||
MONOLITH_CUSTOM_OPTIONS=
|
MONOLITH_CUSTOM_OPTIONS=
|
||||||
@@ -29,6 +32,7 @@ PDF_MAX_BUFFER=
|
|||||||
SCREENSHOT_MAX_BUFFER=
|
SCREENSHOT_MAX_BUFFER=
|
||||||
READABILITY_MAX_BUFFER=
|
READABILITY_MAX_BUFFER=
|
||||||
PREVIEW_MAX_BUFFER=
|
PREVIEW_MAX_BUFFER=
|
||||||
|
IMPORT_LIMIT=
|
||||||
|
|
||||||
# AWS S3 Settings
|
# AWS S3 Settings
|
||||||
SPACES_KEY=
|
SPACES_KEY=
|
||||||
@@ -90,7 +94,6 @@ AUTHELIA_CLIENT_ID=""
|
|||||||
AUTHELIA_CLIENT_SECRET=""
|
AUTHELIA_CLIENT_SECRET=""
|
||||||
AUTHELIA_WELLKNOWN_URL=""
|
AUTHELIA_WELLKNOWN_URL=""
|
||||||
|
|
||||||
|
|
||||||
# Authentik
|
# Authentik
|
||||||
NEXT_PUBLIC_AUTHENTIK_ENABLED=
|
NEXT_PUBLIC_AUTHENTIK_ENABLED=
|
||||||
AUTHENTIK_CUSTOM_NAME=
|
AUTHENTIK_CUSTOM_NAME=
|
||||||
@@ -98,12 +101,25 @@ AUTHENTIK_ISSUER=
|
|||||||
AUTHENTIK_CLIENT_ID=
|
AUTHENTIK_CLIENT_ID=
|
||||||
AUTHENTIK_CLIENT_SECRET=
|
AUTHENTIK_CLIENT_SECRET=
|
||||||
|
|
||||||
|
# Azure AD B2C
|
||||||
|
NEXT_PUBLIC_AZURE_AD_B2C_ENABLED=
|
||||||
|
AZURE_AD_B2C_TENANT_NAME=
|
||||||
|
AZURE_AD_B2C_CLIENT_ID=
|
||||||
|
AZURE_AD_B2C_CLIENT_SECRET=
|
||||||
|
AZURE_AD_B2C_PRIMARY_USER_FLOW=
|
||||||
|
|
||||||
|
# Azure AD
|
||||||
|
NEXT_PUBLIC_AZURE_AD_ENABLED=
|
||||||
|
AZURE_AD_CLIENT_ID=
|
||||||
|
AZURE_AD_CLIENT_SECRET=
|
||||||
|
AZURE_AD_TENANT_ID=
|
||||||
|
|
||||||
# Battle.net
|
# Battle.net
|
||||||
NEXT_PUBLIC_BATTLENET_ENABLED=
|
NEXT_PUBLIC_BATTLENET_ENABLED=
|
||||||
BATTLENET_CUSTOM_NAME=
|
BATTLENET_CUSTOM_NAME=
|
||||||
BATTLENET_CLIENT_ID=
|
BATTLENET_CLIENT_ID=
|
||||||
BATTLENET_CLIENT_SECRET=
|
BATTLENET_CLIENT_SECRET=
|
||||||
BATLLENET_ISSUER=
|
BATTLENET_ISSUER=
|
||||||
|
|
||||||
# Box
|
# Box
|
||||||
NEXT_PUBLIC_BOX_ENABLED=
|
NEXT_PUBLIC_BOX_ENABLED=
|
||||||
@@ -192,8 +208,8 @@ FUSIONAUTH_TENANT_ID=
|
|||||||
# GitHub
|
# GitHub
|
||||||
NEXT_PUBLIC_GITHUB_ENABLED=
|
NEXT_PUBLIC_GITHUB_ENABLED=
|
||||||
GITHUB_CUSTOM_NAME=
|
GITHUB_CUSTOM_NAME=
|
||||||
GITHUB_CLIENT_ID=
|
GITHUB_ID=
|
||||||
GITHUB_CLIENT_SECRET=
|
GITHUB_SECRET=
|
||||||
|
|
||||||
# GitLab
|
# GitLab
|
||||||
NEXT_PUBLIC_GITLAB_ENABLED=
|
NEXT_PUBLIC_GITLAB_ENABLED=
|
||||||
|
|||||||
@@ -81,12 +81,15 @@ const LinkListOptions = ({
|
|||||||
|
|
||||||
toast.dismiss(load);
|
toast.dismiss(load);
|
||||||
|
|
||||||
response.ok &&
|
if (response.ok) {
|
||||||
toast.success(
|
toast.success(
|
||||||
selectedLinks.length === 1
|
selectedLinks.length === 1
|
||||||
? t("link_deleted")
|
? t("link_deleted")
|
||||||
: t("links_deleted", { count: selectedLinks.length })
|
: t("links_deleted", { count: selectedLinks.length })
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
toast.error(response.data as string);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -55,8 +55,11 @@ export default function LinkActions({
|
|||||||
|
|
||||||
toast.dismiss(load);
|
toast.dismiss(load);
|
||||||
|
|
||||||
response.ok &&
|
if (response.ok) {
|
||||||
toast.success(isAlreadyPinned ? t("link_unpinned") : t("link_unpinned"));
|
toast.success(isAlreadyPinned ? t("link_unpinned") : t("link_unpinned"));
|
||||||
|
} else {
|
||||||
|
toast.error(response.data as string);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteLink = async () => {
|
const deleteLink = async () => {
|
||||||
@@ -66,7 +69,11 @@ export default function LinkActions({
|
|||||||
|
|
||||||
toast.dismiss(load);
|
toast.dismiss(load);
|
||||||
|
|
||||||
response.ok && toast.success(t("deleted"));
|
if (response.ok) {
|
||||||
|
toast.success(t("deleted"));
|
||||||
|
} else {
|
||||||
|
toast.error(response.data as string);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -157,7 +157,12 @@ export default function LinkCardCompact({
|
|||||||
// linkInfo={showInfo}
|
// linkInfo={showInfo}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="divider my-0 last:hidden h-[1px]"></div>
|
<div
|
||||||
|
className="last:hidden rounded-none"
|
||||||
|
style={{
|
||||||
|
borderTop: "1px solid var(--fallback-bc,oklch(var(--bc)/0.1))",
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ export default function LinkMasonry({ link, flipDropdown, editMode }: Props) {
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{link.tags[0] && (
|
{link.tags && link.tags[0] && (
|
||||||
<div className="flex gap-1 items-center flex-wrap">
|
<div className="flex gap-1 items-center flex-wrap">
|
||||||
{link.tags.map((e, i) => (
|
{link.tags.map((e, i) => (
|
||||||
<Link
|
<Link
|
||||||
@@ -225,7 +225,7 @@ export default function LinkMasonry({ link, flipDropdown, editMode }: Props) {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
{link.tags[0] && (
|
{link.tags && link.tags[0] && (
|
||||||
<>
|
<>
|
||||||
<p className="text-neutral text-lg mt-3 font-semibold">
|
<p className="text-neutral text-lg mt-3 font-semibold">
|
||||||
{t("tags")}
|
{t("tags")}
|
||||||
|
|||||||
@@ -30,7 +30,11 @@ export default function DeleteLinkModal({ onClose, activeLink }: Props) {
|
|||||||
|
|
||||||
toast.dismiss(load);
|
toast.dismiss(load);
|
||||||
|
|
||||||
response.ok && toast.success(t("deleted"));
|
if (response.ok) {
|
||||||
|
toast.success(t("deleted"));
|
||||||
|
} else {
|
||||||
|
toast.error(response.data as string);
|
||||||
|
}
|
||||||
|
|
||||||
if (router.pathname.startsWith("/links/[id]")) {
|
if (router.pathname.startsWith("/links/[id]")) {
|
||||||
router.push("/dashboard");
|
router.push("/dashboard");
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ export default function DeleteUserModal({ onClose, userId }: Props) {
|
|||||||
|
|
||||||
toast.dismiss(load);
|
toast.dismiss(load);
|
||||||
|
|
||||||
response.ok && toast.success(t("user_deleted"));
|
if (response.ok) {
|
||||||
|
toast.success(t("user_deleted"));
|
||||||
|
} else {
|
||||||
|
toast.error(response.data as string);
|
||||||
|
}
|
||||||
|
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ export default function DeleteTokenModal({ onClose, activeToken }: Props) {
|
|||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
toast.success(t("token_revoked"));
|
toast.success(t("token_revoked"));
|
||||||
|
} else {
|
||||||
|
toast.error(response.data as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
onClose();
|
onClose();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default function PageHeader({
|
|||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<i
|
<i
|
||||||
className={`${icon} text-primary text-3xl sm:text-4xl drop-shadow`}
|
className={`${icon} text-primary sm:text-3xl text-2xl drop-shadow`}
|
||||||
></i>
|
></i>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-3xl capitalize font-thin">{title}</p>
|
<p className="text-3xl capitalize font-thin">{title}</p>
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ export default function ProfileDropdown() {
|
|||||||
const { settings, updateSettings } = useLocalSettingsStore();
|
const { settings, updateSettings } = useLocalSettingsStore();
|
||||||
const { account } = useAccountStore();
|
const { account } = useAccountStore();
|
||||||
|
|
||||||
|
const isAdmin = account.id === Number(process.env.NEXT_PUBLIC_ADMIN || 1);
|
||||||
|
|
||||||
const handleToggle = () => {
|
const handleToggle = () => {
|
||||||
const newTheme = settings.theme === "dark" ? "light" : "dark";
|
const newTheme = settings.theme === "dark" ? "light" : "dark";
|
||||||
updateSettings({ theme: newTheme });
|
updateSettings({ theme: newTheme });
|
||||||
@@ -29,7 +31,11 @@ export default function ProfileDropdown() {
|
|||||||
priority={true}
|
priority={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<ul className="dropdown-content z-[1] menu shadow bg-base-200 border border-neutral-content rounded-box w-40 mt-1">
|
<ul
|
||||||
|
className={`dropdown-content z-[1] menu shadow bg-base-200 border border-neutral-content rounded-box ${
|
||||||
|
isAdmin ? "w-48" : "w-40"
|
||||||
|
} mt-1`}
|
||||||
|
>
|
||||||
<li>
|
<li>
|
||||||
<Link
|
<Link
|
||||||
href="/settings/account"
|
href="/settings/account"
|
||||||
@@ -54,6 +60,18 @@ export default function ProfileDropdown() {
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
{isAdmin ? (
|
||||||
|
<li>
|
||||||
|
<Link
|
||||||
|
href="/admin"
|
||||||
|
onClick={() => (document?.activeElement as HTMLElement)?.blur()}
|
||||||
|
tabIndex={0}
|
||||||
|
role="button"
|
||||||
|
>
|
||||||
|
{t("server_administration")}
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
) : null}
|
||||||
<li>
|
<li>
|
||||||
<div
|
<div
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@@ -52,25 +52,25 @@ export default function Sidebar({ className }: { className?: string }) {
|
|||||||
>
|
>
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<SidebarHighlightLink
|
<SidebarHighlightLink
|
||||||
title={"Dashboard"}
|
title={t("dashboard")}
|
||||||
href={`/dashboard`}
|
href={`/dashboard`}
|
||||||
icon={"bi-house"}
|
icon={"bi-house"}
|
||||||
active={active === `/dashboard`}
|
active={active === `/dashboard`}
|
||||||
/>
|
/>
|
||||||
<SidebarHighlightLink
|
<SidebarHighlightLink
|
||||||
title={"Pinned"}
|
title={t("pinned")}
|
||||||
href={`/links/pinned`}
|
href={`/links/pinned`}
|
||||||
icon={"bi-pin-angle"}
|
icon={"bi-pin-angle"}
|
||||||
active={active === `/links/pinned`}
|
active={active === `/links/pinned`}
|
||||||
/>
|
/>
|
||||||
<SidebarHighlightLink
|
<SidebarHighlightLink
|
||||||
title={"All Links"}
|
title={t("all_links")}
|
||||||
href={`/links`}
|
href={`/links`}
|
||||||
icon={"bi-link-45deg"}
|
icon={"bi-link-45deg"}
|
||||||
active={active === `/links`}
|
active={active === `/links`}
|
||||||
/>
|
/>
|
||||||
<SidebarHighlightLink
|
<SidebarHighlightLink
|
||||||
title={"All Collections"}
|
title={t("all_collections")}
|
||||||
href={`/collections`}
|
href={`/collections`}
|
||||||
icon={"bi-folder"}
|
icon={"bi-folder"}
|
||||||
active={active === `/collections`}
|
active={active === `/collections`}
|
||||||
|
|||||||
@@ -86,17 +86,18 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
|
|||||||
image:
|
image:
|
||||||
user.archiveAsScreenshot && !link.image?.startsWith("archive")
|
user.archiveAsScreenshot && !link.image?.startsWith("archive")
|
||||||
? "pending"
|
? "pending"
|
||||||
: "unavailable",
|
: undefined,
|
||||||
pdf:
|
pdf:
|
||||||
user.archiveAsPDF && !link.pdf?.startsWith("archive")
|
user.archiveAsPDF && !link.pdf?.startsWith("archive")
|
||||||
? "pending"
|
? "pending"
|
||||||
: "unavailable",
|
: undefined,
|
||||||
|
monolith:
|
||||||
|
user.archiveAsMonolith && !link.monolith?.startsWith("archive")
|
||||||
|
? "pending"
|
||||||
|
: undefined,
|
||||||
readable: !link.readable?.startsWith("archive")
|
readable: !link.readable?.startsWith("archive")
|
||||||
? "pending"
|
? "pending"
|
||||||
: undefined,
|
: undefined,
|
||||||
monolith: !link.monolith?.startsWith("archive")
|
|
||||||
? "pending"
|
|
||||||
: undefined,
|
|
||||||
preview: !link.readable?.startsWith("archive")
|
preview: !link.readable?.startsWith("archive")
|
||||||
? "pending"
|
? "pending"
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export default async function getLink(userId: number, query: LinkRequestQuery) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const links = await prisma.link.findMany({
|
const links = await prisma.link.findMany({
|
||||||
take: Number(process.env.PAGINATION_TAKE_COUNT) || 20,
|
take: Number(process.env.PAGINATION_TAKE_COUNT) || 50,
|
||||||
skip: query.cursor ? 1 : undefined,
|
skip: query.cursor ? 1 : undefined,
|
||||||
cursor: query.cursor ? { id: query.cursor } : undefined,
|
cursor: query.cursor ? { id: query.cursor } : undefined,
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export default async function updateLinkById(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return { response: updatedLink, status: 200 };
|
// return { response: updatedLink, status: 200 };
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetCollectionIsAccessible = await getPermission({
|
const targetCollectionIsAccessible = await getPermission({
|
||||||
@@ -60,9 +60,6 @@ export default async function updateLinkById(
|
|||||||
(e: UsersAndCollections) => e.userId === userId && e.canUpdate
|
(e: UsersAndCollections) => e.userId === userId && e.canUpdate
|
||||||
);
|
);
|
||||||
|
|
||||||
const targetCollectionsAccessible =
|
|
||||||
targetCollectionIsAccessible?.ownerId === userId;
|
|
||||||
|
|
||||||
const targetCollectionMatchesData = data.collection.id
|
const targetCollectionMatchesData = data.collection.id
|
||||||
? data.collection.id === targetCollectionIsAccessible?.id
|
? data.collection.id === targetCollectionIsAccessible?.id
|
||||||
: true && data.collection.name
|
: true && data.collection.name
|
||||||
@@ -71,12 +68,7 @@ export default async function updateLinkById(
|
|||||||
? data.collection.ownerId === targetCollectionIsAccessible?.ownerId
|
? data.collection.ownerId === targetCollectionIsAccessible?.ownerId
|
||||||
: true;
|
: true;
|
||||||
|
|
||||||
if (!targetCollectionsAccessible)
|
if (!targetCollectionMatchesData)
|
||||||
return {
|
|
||||||
response: "Target collection is not accessible.",
|
|
||||||
status: 401,
|
|
||||||
};
|
|
||||||
else if (!targetCollectionMatchesData)
|
|
||||||
return {
|
return {
|
||||||
response: "Target collection does not match the data.",
|
response: "Target collection does not match the data.",
|
||||||
status: 401,
|
status: 401,
|
||||||
|
|||||||
@@ -63,11 +63,21 @@ async function processBookmarks(
|
|||||||
) as Element;
|
) as Element;
|
||||||
|
|
||||||
if (collectionName) {
|
if (collectionName) {
|
||||||
collectionId = await createCollection(
|
const collectionNameContent = (collectionName.children[0] as TextNode)?.content;
|
||||||
userId,
|
if (collectionNameContent) {
|
||||||
(collectionName.children[0] as TextNode).content,
|
collectionId = await createCollection(
|
||||||
parentCollectionId
|
userId,
|
||||||
);
|
collectionNameContent,
|
||||||
|
parentCollectionId
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Handle the case when the collection name is empty
|
||||||
|
collectionId = await createCollection(
|
||||||
|
userId,
|
||||||
|
"Untitled Collection",
|
||||||
|
parentCollectionId
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await processBookmarks(
|
await processBookmarks(
|
||||||
userId,
|
userId,
|
||||||
@@ -264,3 +274,4 @@ function processNodes(nodes: Node[]) {
|
|||||||
nodes.forEach(findAndProcessDL);
|
nodes.forEach(findAndProcessDL);
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export default async function getLink(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const links = await prisma.link.findMany({
|
const links = await prisma.link.findMany({
|
||||||
take: Number(process.env.PAGINATION_TAKE_COUNT) || 20,
|
take: Number(process.env.PAGINATION_TAKE_COUNT) || 50,
|
||||||
skip: query.cursor ? 1 : undefined,
|
skip: query.cursor ? 1 : undefined,
|
||||||
cursor: query.cursor ? { id: query.cursor } : undefined,
|
cursor: query.cursor ? { id: query.cursor } : undefined,
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export default async function isServerAdmin({ req }: Props): Promise<boolean> {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (findUser?.username === process.env.ADMINISTRATOR) {
|
if (findUser?.id === Number(process.env.NEXT_PUBLIC_ADMIN || 1)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
i18n: {
|
i18n: {
|
||||||
defaultLocale: "en",
|
defaultLocale: "en",
|
||||||
locales: ["en"],
|
locales: ["en","it"],
|
||||||
},
|
},
|
||||||
reloadOnPrerender: process.env.NODE_ENV === "development",
|
reloadOnPrerender: process.env.NODE_ENV === "development",
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "linkwarden",
|
"name": "linkwarden",
|
||||||
"version": "v2.6.0",
|
"version": "v2.6.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": "https://github.com/linkwarden/linkwarden.git",
|
"repository": "https://github.com/linkwarden/linkwarden.git",
|
||||||
"author": "Daniel31X13 <daniel31x13@gmail.com>",
|
"author": "Daniel31X13 <daniel31x13@gmail.com>",
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import DeleteUserModal from "@/components/ModalContent/DeleteUserModal";
|
|
||||||
import NewUserModal from "@/components/ModalContent/NewUserModal";
|
import NewUserModal from "@/components/ModalContent/NewUserModal";
|
||||||
import useUserStore from "@/store/admin/users";
|
import useUserStore from "@/store/admin/users";
|
||||||
import { User as U } from "@prisma/client";
|
import { User as U } from "@prisma/client";
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
return res.send(file);
|
return res.send(file);
|
||||||
}
|
}
|
||||||
} else if (req.method === "POST") {
|
} else if (req.method === "POST") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const user = await verifyUser({ req, res });
|
const user = await verifyUser({ req, res });
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
@@ -86,14 +92,18 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!collectionPermissions)
|
if (!collectionPermissions)
|
||||||
return { response: "Collection is not accessible.", status: 400 };
|
return res.status(400).json({
|
||||||
|
response: "Collection is not accessible.",
|
||||||
|
});
|
||||||
|
|
||||||
const memberHasAccess = collectionPermissions.members.some(
|
const memberHasAccess = collectionPermissions.members.some(
|
||||||
(e: UsersAndCollections) => e.userId === user.id && e.canCreate
|
(e: UsersAndCollections) => e.userId === user.id && e.canCreate
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!(collectionPermissions.ownerId === user.id || memberHasAccess))
|
if (!(collectionPermissions.ownerId === user.id || memberHasAccess))
|
||||||
return { response: "Collection is not accessible.", status: 400 };
|
return res.status(400).json({
|
||||||
|
response: "Collection is not accessible.",
|
||||||
|
});
|
||||||
|
|
||||||
// await uploadHandler(linkId, )
|
// await uploadHandler(linkId, )
|
||||||
|
|
||||||
@@ -108,10 +118,10 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (numberOfLinksTheUserHas > MAX_LINKS_PER_USER)
|
if (numberOfLinksTheUserHas > MAX_LINKS_PER_USER)
|
||||||
return {
|
return res.status(400).json({
|
||||||
response: `Each collection owner can only have a maximum of ${MAX_LINKS_PER_USER} Links.`,
|
response:
|
||||||
status: 400,
|
"Each collection owner can only have a maximum of ${MAX_LINKS_PER_USER} Links.",
|
||||||
};
|
});
|
||||||
|
|
||||||
const NEXT_PUBLIC_MAX_FILE_BUFFER = Number(
|
const NEXT_PUBLIC_MAX_FILE_BUFFER = Number(
|
||||||
process.env.NEXT_PUBLIC_MAX_FILE_BUFFER || 10
|
process.env.NEXT_PUBLIC_MAX_FILE_BUFFER || 10
|
||||||
|
|||||||
@@ -1,27 +1,31 @@
|
|||||||
import { prisma } from "@/lib/api/db";
|
import { prisma } from "@/lib/api/db";
|
||||||
import NextAuth from "next-auth/next";
|
|
||||||
import CredentialsProvider from "next-auth/providers/credentials";
|
|
||||||
import bcrypt from "bcrypt";
|
|
||||||
import EmailProvider from "next-auth/providers/email";
|
|
||||||
import { PrismaAdapter } from "@auth/prisma-adapter";
|
|
||||||
import { Adapter } from "next-auth/adapters";
|
|
||||||
import sendVerificationRequest from "@/lib/api/sendVerificationRequest";
|
import sendVerificationRequest from "@/lib/api/sendVerificationRequest";
|
||||||
import { Provider } from "next-auth/providers";
|
|
||||||
import verifySubscription from "@/lib/api/verifySubscription";
|
import verifySubscription from "@/lib/api/verifySubscription";
|
||||||
|
import { PrismaAdapter } from "@auth/prisma-adapter";
|
||||||
|
import bcrypt from "bcrypt";
|
||||||
|
import { randomBytes } from "crypto";
|
||||||
|
import type { NextApiRequest, NextApiResponse } from "next";
|
||||||
|
import { Adapter } from "next-auth/adapters";
|
||||||
|
import NextAuth from "next-auth/next";
|
||||||
|
import { Provider } from "next-auth/providers";
|
||||||
import FortyTwoProvider from "next-auth/providers/42-school";
|
import FortyTwoProvider from "next-auth/providers/42-school";
|
||||||
import AppleProvider from "next-auth/providers/apple";
|
import AppleProvider from "next-auth/providers/apple";
|
||||||
import AtlassianProvider from "next-auth/providers/atlassian";
|
import AtlassianProvider from "next-auth/providers/atlassian";
|
||||||
import Auth0Provider from "next-auth/providers/auth0";
|
import Auth0Provider from "next-auth/providers/auth0";
|
||||||
import AuthentikProvider from "next-auth/providers/authentik";
|
import AuthentikProvider from "next-auth/providers/authentik";
|
||||||
|
import AzureAdProvider from "next-auth/providers/azure-ad";
|
||||||
|
import AzureAdB2CProvider from "next-auth/providers/azure-ad-b2c";
|
||||||
import BattleNetProvider, {
|
import BattleNetProvider, {
|
||||||
BattleNetIssuer,
|
BattleNetIssuer,
|
||||||
} from "next-auth/providers/battlenet";
|
} from "next-auth/providers/battlenet";
|
||||||
import BoxProvider from "next-auth/providers/box";
|
import BoxProvider from "next-auth/providers/box";
|
||||||
import CognitoProvider from "next-auth/providers/cognito";
|
import CognitoProvider from "next-auth/providers/cognito";
|
||||||
import CoinbaseProvider from "next-auth/providers/coinbase";
|
import CoinbaseProvider from "next-auth/providers/coinbase";
|
||||||
|
import CredentialsProvider from "next-auth/providers/credentials";
|
||||||
import DiscordProvider from "next-auth/providers/discord";
|
import DiscordProvider from "next-auth/providers/discord";
|
||||||
import DropboxProvider from "next-auth/providers/dropbox";
|
import DropboxProvider from "next-auth/providers/dropbox";
|
||||||
import DuendeIDS6Provider from "next-auth/providers/duende-identity-server6";
|
import DuendeIDS6Provider from "next-auth/providers/duende-identity-server6";
|
||||||
|
import EmailProvider from "next-auth/providers/email";
|
||||||
import EVEOnlineProvider from "next-auth/providers/eveonline";
|
import EVEOnlineProvider from "next-auth/providers/eveonline";
|
||||||
import FacebookProvider from "next-auth/providers/facebook";
|
import FacebookProvider from "next-auth/providers/facebook";
|
||||||
import FaceItProvider from "next-auth/providers/faceit";
|
import FaceItProvider from "next-auth/providers/faceit";
|
||||||
@@ -64,8 +68,6 @@ import ZitadelProvider from "next-auth/providers/zitadel";
|
|||||||
import ZohoProvider from "next-auth/providers/zoho";
|
import ZohoProvider from "next-auth/providers/zoho";
|
||||||
import ZoomProvider from "next-auth/providers/zoom";
|
import ZoomProvider from "next-auth/providers/zoom";
|
||||||
import * as process from "process";
|
import * as process from "process";
|
||||||
import type { NextApiRequest, NextApiResponse } from "next";
|
|
||||||
import { randomBytes } from "crypto";
|
|
||||||
|
|
||||||
const emailEnabled =
|
const emailEnabled =
|
||||||
process.env.EMAIL_FROM && process.env.EMAIL_SERVER ? true : false;
|
process.env.EMAIL_FROM && process.env.EMAIL_SERVER ? true : false;
|
||||||
@@ -317,13 +319,65 @@ if (process.env.NEXT_PUBLIC_AUTHENTIK_ENABLED === "true") {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Azure AD B2C
|
||||||
|
if (process.env.NEXT_PUBLIC_AZURE_AD_ENABLED === "true") {
|
||||||
|
providers.push(
|
||||||
|
AzureAdB2CProvider({
|
||||||
|
tenantId: process.env.AZURE_AD_B2C_TENANT_NAME,
|
||||||
|
clientId: process.env.AZURE_AD_B2C_CLIENT_ID!,
|
||||||
|
clientSecret: process.env.AZURE_AD_B2C_CLIENT_SECRET!,
|
||||||
|
primaryUserFlow: process.env.AZURE_AD_B2C_PRIMARY_USER_FLOW,
|
||||||
|
authorization: { params: { scope: "offline_access openid" } },
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const _linkAccount = adapter.linkAccount;
|
||||||
|
adapter.linkAccount = (account) => {
|
||||||
|
const {
|
||||||
|
"not-before-policy": _,
|
||||||
|
refresh_expires_in,
|
||||||
|
refresh_token_expires_in,
|
||||||
|
not_before,
|
||||||
|
id_token_expires_in,
|
||||||
|
profile_info,
|
||||||
|
...data
|
||||||
|
} = account;
|
||||||
|
return _linkAccount ? _linkAccount(data) : undefined;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Azure AD
|
||||||
|
if (process.env.NEXT_PUBLIC_AZURE_AD_ENABLED === "true") {
|
||||||
|
providers.push(
|
||||||
|
AzureAdProvider({
|
||||||
|
clientId: process.env.AZURE_AD_CLIENT_ID!,
|
||||||
|
clientSecret: process.env.AZURE_AD_CLIENT_SECRET!,
|
||||||
|
tenantId: process.env.AZURE_AD_TENANT_ID,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const _linkAccount = adapter.linkAccount;
|
||||||
|
adapter.linkAccount = (account) => {
|
||||||
|
const {
|
||||||
|
"not-before-policy": _,
|
||||||
|
refresh_expires_in,
|
||||||
|
token_type,
|
||||||
|
expires_in,
|
||||||
|
ext_expires_in,
|
||||||
|
access_token,
|
||||||
|
...data
|
||||||
|
} = account;
|
||||||
|
return _linkAccount ? _linkAccount(data) : undefined;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Battle.net
|
// Battle.net
|
||||||
if (process.env.NEXT_PUBLIC_BATTLENET_ENABLED === "true") {
|
if (process.env.NEXT_PUBLIC_BATTLENET_ENABLED === "true") {
|
||||||
providers.push(
|
providers.push(
|
||||||
BattleNetProvider({
|
BattleNetProvider({
|
||||||
clientId: process.env.BATTLENET_CLIENT_ID!,
|
clientId: process.env.BATTLENET_CLIENT_ID!,
|
||||||
clientSecret: process.env.BATTLENET_CLIENT_SECRET!,
|
clientSecret: process.env.BATTLENET_CLIENT_SECRET!,
|
||||||
issuer: process.env.BATLLENET_ISSUER as BattleNetIssuer,
|
issuer: process.env.BATTLENET_ISSUER as BattleNetIssuer,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1146,6 +1200,28 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
if (trigger === "signIn" || trigger === "signUp")
|
if (trigger === "signIn" || trigger === "signUp")
|
||||||
token.id = user?.id as number;
|
token.id = user?.id as number;
|
||||||
|
|
||||||
|
if (trigger === "signUp") {
|
||||||
|
const checkIfUserExists = await prisma.user.findUnique({
|
||||||
|
where: {
|
||||||
|
id: token.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checkIfUserExists && !checkIfUserExists.username) {
|
||||||
|
const autoGeneratedUsername =
|
||||||
|
"user" + Math.round(Math.random() * 1000000000);
|
||||||
|
|
||||||
|
await prisma.user.update({
|
||||||
|
where: {
|
||||||
|
id: token.id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
username: autoGeneratedUsername,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
},
|
},
|
||||||
async session({ session, token }) {
|
async session({ session, token }) {
|
||||||
|
|||||||
@@ -7,6 +7,12 @@ export default async function forgotPassword(
|
|||||||
res: NextApiResponse
|
res: NextApiResponse
|
||||||
) {
|
) {
|
||||||
if (req.method === "POST") {
|
if (req.method === "POST") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const email = req.body.email;
|
const email = req.body.email;
|
||||||
|
|
||||||
if (!email) {
|
if (!email) {
|
||||||
|
|||||||
@@ -7,6 +7,12 @@ export default async function resetPassword(
|
|||||||
res: NextApiResponse
|
res: NextApiResponse
|
||||||
) {
|
) {
|
||||||
if (req.method === "POST") {
|
if (req.method === "POST") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const token = req.body.token;
|
const token = req.body.token;
|
||||||
const password = req.body.password;
|
const password = req.body.password;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,12 @@ export default async function verifyEmail(
|
|||||||
res: NextApiResponse
|
res: NextApiResponse
|
||||||
) {
|
) {
|
||||||
if (req.method === "POST") {
|
if (req.method === "POST") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const token = req.query.token;
|
const token = req.query.token;
|
||||||
|
|
||||||
if (!token || typeof token !== "string") {
|
if (!token || typeof token !== "string") {
|
||||||
|
|||||||
@@ -19,9 +19,21 @@ export default async function collections(
|
|||||||
.status(collections.status)
|
.status(collections.status)
|
||||||
.json({ response: collections.response });
|
.json({ response: collections.response });
|
||||||
} else if (req.method === "PUT") {
|
} else if (req.method === "PUT") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const updated = await updateCollectionById(user.id, collectionId, req.body);
|
const updated = await updateCollectionById(user.id, collectionId, req.body);
|
||||||
return res.status(updated.status).json({ response: updated.response });
|
return res.status(updated.status).json({ response: updated.response });
|
||||||
} else if (req.method === "DELETE") {
|
} else if (req.method === "DELETE") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const deleted = await deleteCollectionById(user.id, collectionId);
|
const deleted = await deleteCollectionById(user.id, collectionId);
|
||||||
return res.status(deleted.status).json({ response: deleted.response });
|
return res.status(deleted.status).json({ response: deleted.response });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ export default async function collections(
|
|||||||
.status(collections.status)
|
.status(collections.status)
|
||||||
.json({ response: collections.response });
|
.json({ response: collections.response });
|
||||||
} else if (req.method === "POST") {
|
} else if (req.method === "POST") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const newCollection = await postCollection(req.body, user.id);
|
const newCollection = await postCollection(req.body, user.id);
|
||||||
return res
|
return res
|
||||||
.status(newCollection.status)
|
.status(newCollection.status)
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (req.method === "PUT") {
|
if (req.method === "PUT") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
link?.lastPreserved &&
|
link?.lastPreserved &&
|
||||||
getTimezoneDifferenceInMinutes(new Date(), link?.lastPreserved) <
|
getTimezoneDifferenceInMinutes(new Date(), link?.lastPreserved) <
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
response: updated.response,
|
response: updated.response,
|
||||||
});
|
});
|
||||||
} else if (req.method === "PUT") {
|
} else if (req.method === "PUT") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const updated = await updateLinkById(
|
const updated = await updateLinkById(
|
||||||
user.id,
|
user.id,
|
||||||
Number(req.query.id),
|
Number(req.query.id),
|
||||||
@@ -23,6 +29,12 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
response: updated.response,
|
response: updated.response,
|
||||||
});
|
});
|
||||||
} else if (req.method === "DELETE") {
|
} else if (req.method === "DELETE") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const deleted = await deleteLinkById(user.id, Number(req.query.id));
|
const deleted = await deleteLinkById(user.id, Number(req.query.id));
|
||||||
return res.status(deleted.status).json({
|
return res.status(deleted.status).json({
|
||||||
response: deleted.response,
|
response: deleted.response,
|
||||||
|
|||||||
@@ -37,11 +37,23 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
const links = await getLinks(user.id, convertedData);
|
const links = await getLinks(user.id, convertedData);
|
||||||
return res.status(links.status).json({ response: links.response });
|
return res.status(links.status).json({ response: links.response });
|
||||||
} else if (req.method === "POST") {
|
} else if (req.method === "POST") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const newlink = await postLink(req.body, user.id);
|
const newlink = await postLink(req.body, user.id);
|
||||||
return res.status(newlink.status).json({
|
return res.status(newlink.status).json({
|
||||||
response: newlink.response,
|
response: newlink.response,
|
||||||
});
|
});
|
||||||
} else if (req.method === "PUT") {
|
} else if (req.method === "PUT") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const updated = await updateLinks(
|
const updated = await updateLinks(
|
||||||
user.id,
|
user.id,
|
||||||
req.body.links,
|
req.body.links,
|
||||||
@@ -52,6 +64,12 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
response: updated.response,
|
response: updated.response,
|
||||||
});
|
});
|
||||||
} else if (req.method === "DELETE") {
|
} else if (req.method === "DELETE") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const deleted = await deleteLinksById(user.id, req.body.linkIds);
|
const deleted = await deleteLinksById(user.id, req.body.linkIds);
|
||||||
return res.status(deleted.status).json({
|
return res.status(deleted.status).json({
|
||||||
response: deleted.response,
|
response: deleted.response,
|
||||||
|
|||||||
@@ -55,6 +55,20 @@ export function getLogins() {
|
|||||||
name: process.env.AUTHENTIK_CUSTOM_NAME ?? "Authentik",
|
name: process.env.AUTHENTIK_CUSTOM_NAME ?? "Authentik",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Azure AD B2C
|
||||||
|
if (process.env.NEXT_PUBLIC_AZURE_AD_B2C_ENABLED === "true") {
|
||||||
|
buttonAuths.push({
|
||||||
|
method: "azure-ad-b2c",
|
||||||
|
name: process.env.AZURE_AD_B2C_CUSTOM_NAME ?? "Azure AD B2C",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Azure AD
|
||||||
|
if (process.env.NEXT_PUBLIC_AZURE_AD_ENABLED === "true") {
|
||||||
|
buttonAuths.push({
|
||||||
|
method: "azure-ad",
|
||||||
|
name: process.env.AZURE_AD_CUSTOM_NAME ?? "Azure AD",
|
||||||
|
});
|
||||||
|
}
|
||||||
// Battle.net
|
// Battle.net
|
||||||
if (process.env.NEXT_PUBLIC_BATTLENET_ENABLED === "true") {
|
if (process.env.NEXT_PUBLIC_BATTLENET_ENABLED === "true") {
|
||||||
buttonAuths.push({
|
buttonAuths.push({
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import importFromWallabag from "@/lib/api/controllers/migration/importFromWallab
|
|||||||
export const config = {
|
export const config = {
|
||||||
api: {
|
api: {
|
||||||
bodyParser: {
|
bodyParser: {
|
||||||
sizeLimit: "10mb",
|
sizeLimit: process.env.IMPORT_LIMIT
|
||||||
|
? process.env.IMPORT_LIMIT + "mb"
|
||||||
|
: "10mb",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -28,6 +30,12 @@ export default async function users(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
.status(data.status)
|
.status(data.status)
|
||||||
.json(data.response);
|
.json(data.response);
|
||||||
} else if (req.method === "POST") {
|
} else if (req.method === "POST") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const request: MigrationRequest = JSON.parse(req.body);
|
const request: MigrationRequest = JSON.parse(req.body);
|
||||||
|
|
||||||
let data;
|
let data;
|
||||||
|
|||||||
@@ -10,9 +10,21 @@ export default async function tags(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
const tagId = Number(req.query.id);
|
const tagId = Number(req.query.id);
|
||||||
|
|
||||||
if (req.method === "PUT") {
|
if (req.method === "PUT") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const tags = await updeteTagById(user.id, tagId, req.body);
|
const tags = await updeteTagById(user.id, tagId, req.body);
|
||||||
return res.status(tags.status).json({ response: tags.response });
|
return res.status(tags.status).json({ response: tags.response });
|
||||||
} else if (req.method === "DELETE") {
|
} else if (req.method === "DELETE") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const tags = await deleteTagById(user.id, tagId);
|
const tags = await deleteTagById(user.id, tagId);
|
||||||
return res.status(tags.status).json({ response: tags.response });
|
return res.status(tags.status).json({ response: tags.response });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,12 @@ export default async function token(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
if (req.method === "DELETE") {
|
if (req.method === "DELETE") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const deleted = await deleteToken(user.id, Number(req.query.id) as number);
|
const deleted = await deleteToken(user.id, Number(req.query.id) as number);
|
||||||
return res.status(deleted.status).json({ response: deleted.response });
|
return res.status(deleted.status).json({ response: deleted.response });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ export default async function tokens(
|
|||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
if (req.method === "POST") {
|
if (req.method === "POST") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const token = await postToken(JSON.parse(req.body), user.id);
|
const token = await postToken(JSON.parse(req.body), user.id);
|
||||||
return res.status(token.status).json({ response: token.response });
|
return res.status(token.status).json({ response: token.response });
|
||||||
} else if (req.method === "GET") {
|
} else if (req.method === "GET") {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default async function users(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const isServerAdmin = process.env.ADMINISTRATOR === user?.username;
|
const isServerAdmin = user?.id === Number(process.env.NEXT_PUBLIC_ADMIN || 1);
|
||||||
|
|
||||||
const userId = isServerAdmin ? Number(req.query.id) : token.id;
|
const userId = isServerAdmin ? Number(req.query.id) : token.id;
|
||||||
|
|
||||||
@@ -58,9 +58,21 @@ export default async function users(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (req.method === "PUT") {
|
if (req.method === "PUT") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const updated = await updateUserById(userId, req.body);
|
const updated = await updateUserById(userId, req.body);
|
||||||
return res.status(updated.status).json({ response: updated.response });
|
return res.status(updated.status).json({ response: updated.response });
|
||||||
} else if (req.method === "DELETE") {
|
} else if (req.method === "DELETE") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const updated = await deleteUserById(userId, req.body, isServerAdmin);
|
const updated = await deleteUserById(userId, req.body, isServerAdmin);
|
||||||
return res.status(updated.status).json({ response: updated.response });
|
return res.status(updated.status).json({ response: updated.response });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,18 @@ import verifyUser from "@/lib/api/verifyUser";
|
|||||||
|
|
||||||
export default async function users(req: NextApiRequest, res: NextApiResponse) {
|
export default async function users(req: NextApiRequest, res: NextApiResponse) {
|
||||||
if (req.method === "POST") {
|
if (req.method === "POST") {
|
||||||
|
if (process.env.NEXT_PUBLIC_DEMO === "true")
|
||||||
|
return res.status(400).json({
|
||||||
|
response:
|
||||||
|
"This action is disabled because this is a read-only demo of Linkwarden.",
|
||||||
|
});
|
||||||
|
|
||||||
const response = await postUser(req, res);
|
const response = await postUser(req, res);
|
||||||
return res.status(response.status).json({ response: response.response });
|
return res.status(response.status).json({ response: response.response });
|
||||||
} else if (req.method === "GET") {
|
} else if (req.method === "GET") {
|
||||||
const user = await verifyUser({ req, res });
|
const user = await verifyUser({ req, res });
|
||||||
if (!user || process.env.ADMINISTRATOR !== user.username)
|
|
||||||
|
if (!user || user.id !== Number(process.env.NEXT_PUBLIC_ADMIN || 1))
|
||||||
return res.status(401).json({ response: "Unauthorized..." });
|
return res.status(401).json({ response: "Unauthorized..." });
|
||||||
|
|
||||||
const response = await getUsers();
|
const response = await getUsers();
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ export default function Index() {
|
|||||||
style={{ color: activeCollection?.color }}
|
style={{ color: activeCollection?.color }}
|
||||||
></i>
|
></i>
|
||||||
|
|
||||||
<p className="sm:text-4xl text-3xl capitalize w-full py-1 break-words hyphens-auto font-thin">
|
<p className="sm:text-3xl text-2xl capitalize w-full py-1 break-words hyphens-auto font-thin">
|
||||||
{activeCollection?.name}
|
{activeCollection?.name}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import CenteredForm from "@/layouts/CenteredForm";
|
import CenteredForm from "@/layouts/CenteredForm";
|
||||||
import { signIn } from "next-auth/react";
|
import { signIn } from "next-auth/react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import React, { useState } from "react";
|
import { useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { useTranslation } from "next-i18next";
|
import { useTranslation } from "next-i18next";
|
||||||
import getServerSideProps from "@/lib/client/getServerSideProps";
|
import getServerSideProps from "@/lib/client/getServerSideProps";
|
||||||
|
|||||||
@@ -92,6 +92,66 @@ export default function Login({
|
|||||||
{t("enter_credentials")}
|
{t("enter_credentials")}
|
||||||
</p>
|
</p>
|
||||||
<hr className="border-1 border-sky-100 dark:border-neutral-700" />
|
<hr className="border-1 border-sky-100 dark:border-neutral-700" />
|
||||||
|
|
||||||
|
{process.env.NEXT_PUBLIC_DEMO === "true" &&
|
||||||
|
process.env.NEXT_PUBLIC_DEMO_USERNAME &&
|
||||||
|
process.env.NEXT_PUBLIC_DEMO_PASSWORD && (
|
||||||
|
<div className="p-3 shadow-lg border border-primary rounded-xl">
|
||||||
|
<div className="flex flex-col gap-2 items-center text-center w-full">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
className="stroke-info h-6 w-6 shrink-0"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeWidth="2"
|
||||||
|
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
||||||
|
></path>
|
||||||
|
</svg>
|
||||||
|
<p className="font-bold">{t("demo_title")}</p>
|
||||||
|
</div>
|
||||||
|
<div className="text-xs">{t("demo_desc")}</div>
|
||||||
|
|
||||||
|
<div className="text-xs">
|
||||||
|
{t("demo_desc_2")}{" "}
|
||||||
|
<a
|
||||||
|
href="https://cloud.linkwarden.app"
|
||||||
|
target="_blank"
|
||||||
|
className="font-bold"
|
||||||
|
>
|
||||||
|
cloud.linkwarden.app
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="btn btn-sm btn-primary w-full"
|
||||||
|
onClick={async () => {
|
||||||
|
const load = toast.loading(t("authenticating"));
|
||||||
|
|
||||||
|
setForm({
|
||||||
|
username: process.env
|
||||||
|
.NEXT_PUBLIC_DEMO_USERNAME as string,
|
||||||
|
password: process.env
|
||||||
|
.NEXT_PUBLIC_DEMO_PASSWORD as string,
|
||||||
|
});
|
||||||
|
await signIn("credentials", {
|
||||||
|
username: process.env.NEXT_PUBLIC_DEMO_USERNAME,
|
||||||
|
password: process.env.NEXT_PUBLIC_DEMO_PASSWORD,
|
||||||
|
redirect: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
toast.dismiss(load);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("demo_button")}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
|
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
|
||||||
{availableLogins.emailEnabled === "true"
|
{availableLogins.emailEnabled === "true"
|
||||||
|
|||||||
+2
-2
@@ -145,7 +145,7 @@ export default function Index() {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
autoFocus
|
autoFocus
|
||||||
className="sm:text-4xl text-3xl capitalize bg-transparent h-10 w-3/4 outline-none border-b border-b-neutral-content"
|
className="sm:text-3xl text-2xl bg-transparent h-10 w-3/4 outline-none border-b border-b-neutral-content"
|
||||||
value={newTagName}
|
value={newTagName}
|
||||||
onChange={(e) => setNewTagName(e.target.value)}
|
onChange={(e) => setNewTagName(e.target.value)}
|
||||||
/>
|
/>
|
||||||
@@ -167,7 +167,7 @@ export default function Index() {
|
|||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<p className="sm:text-4xl text-3xl capitalize">
|
<p className="sm:text-3xl text-2xl capitalize">
|
||||||
{activeTag?.name}
|
{activeTag?.name}
|
||||||
</p>
|
</p>
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
|
|||||||
@@ -363,5 +363,12 @@
|
|||||||
"hide_link_details": "Hide Link Details",
|
"hide_link_details": "Hide Link Details",
|
||||||
"link_pinned": "Link Pinned!",
|
"link_pinned": "Link Pinned!",
|
||||||
"link_unpinned": "Link Unpinned!",
|
"link_unpinned": "Link Unpinned!",
|
||||||
"webpage": "Webpage"
|
"webpage": "Webpage",
|
||||||
|
"server_administration": "Server Administration",
|
||||||
|
"all_collections": "All Collections",
|
||||||
|
"dashboard": "Dashboard",
|
||||||
|
"demo_title": "Demo Only",
|
||||||
|
"demo_desc": "This is only a demo instance of Linkwarden and uploads are disabled.",
|
||||||
|
"demo_desc_2": "If you want to try out the full version, you can sign up for a free trial at:",
|
||||||
|
"demo_button": "Login as demo user"
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,370 @@
|
|||||||
|
{
|
||||||
|
"user_administration": "Amministrazione Utenti",
|
||||||
|
"search_users": "Cerca Utenti",
|
||||||
|
"no_users_found": "Nessun utente trovato.",
|
||||||
|
"no_user_found_in_search": "Nessun utente trovato con la query di ricerca specificata.",
|
||||||
|
"username": "Nome utente",
|
||||||
|
"email": "Email",
|
||||||
|
"subscribed": "Iscritto",
|
||||||
|
"created_at": "Creato il",
|
||||||
|
"not_available": "N/D",
|
||||||
|
"check_your_email": "Per favore controlla la tua email",
|
||||||
|
"authenticating": "Autenticazione in corso...",
|
||||||
|
"verification_email_sent": "Email di verifica inviata.",
|
||||||
|
"verification_email_sent_desc": "Un link di accesso è stato inviato al tuo indirizzo email. Se non vedi l'email, controlla la cartella dello spam.",
|
||||||
|
"resend_email": "Reinvia Email",
|
||||||
|
"invalid_credentials": "Credenziali non valide.",
|
||||||
|
"fill_all_fields": "Per favore compila tutti i campi.",
|
||||||
|
"enter_credentials": "Inserisci le tue credenziali",
|
||||||
|
"username_or_email": "Nome utente o Email",
|
||||||
|
"password": "Password",
|
||||||
|
"confirm_password": "Conferma Password",
|
||||||
|
"forgot_password": "Password dimenticata?",
|
||||||
|
"login": "Accedi",
|
||||||
|
"or_continue_with": "O continua con",
|
||||||
|
"new_here": "Nuovo qui?",
|
||||||
|
"sign_up": "Registrati",
|
||||||
|
"sign_in_to_your_account": "Accedi al tuo account",
|
||||||
|
"dashboard_desc": "Una breve panoramica dei tuoi dati",
|
||||||
|
"link": "Link",
|
||||||
|
"links": "Links",
|
||||||
|
"collection": "Collezione",
|
||||||
|
"collections": "Collezioni",
|
||||||
|
"tag": "Tag",
|
||||||
|
"tags": "Tags",
|
||||||
|
"recent": "Recenti",
|
||||||
|
"recent_links_desc": "Link aggiunti di recente",
|
||||||
|
"view_all": "Vedi tutti",
|
||||||
|
"view_added_links_here": "Visualizza i tuoi Link aggiunti di recente qui!",
|
||||||
|
"view_added_links_here_desc": "Questa sezione mostrerà i tuoi ultimi Link aggiunti in tutte le Collezioni a cui hai accesso.",
|
||||||
|
"add_link": "Aggiungi Nuovo Link",
|
||||||
|
"import_links": "Importa Links",
|
||||||
|
"from_linkwarden": "Da Linkwarden",
|
||||||
|
"from_html": "Da file HTML dei segnalibri",
|
||||||
|
"from_wallabag": "Da Wallabag (file JSON)",
|
||||||
|
"pinned": "Fissati",
|
||||||
|
"pinned_links_desc": "I tuoi Link fissati",
|
||||||
|
"pin_favorite_links_here": "Fissa i tuoi Link preferiti qui!",
|
||||||
|
"pin_favorite_links_here_desc": "Puoi fissare i tuoi Link preferiti cliccando sui tre puntini su ogni Link e selezionando Fissa alla Dashboard.",
|
||||||
|
"sending_password_link": "Invio del link per il recupero della password...",
|
||||||
|
"password_email_prompt": "Inserisci la tua email per inviarti un link per creare una nuova password.",
|
||||||
|
"send_reset_link": "Invia Link di Reset",
|
||||||
|
"reset_email_sent_desc": "Controlla la tua email per un link per reimpostare la password. Se non appare entro pochi minuti, controlla la cartella dello spam.",
|
||||||
|
"back_to_login": "Torna al Login",
|
||||||
|
"email_sent": "Email Inviata!",
|
||||||
|
"passwords_mismatch": "Le password non corrispondono.",
|
||||||
|
"password_too_short": "Le password devono essere di almeno 8 caratteri.",
|
||||||
|
"creating_account": "Creazione dell'Account in corso...",
|
||||||
|
"account_created": "Account Creato!",
|
||||||
|
"trial_offer_desc": "Sblocca {{count}} giorni di Servizio Premium gratuitamente!",
|
||||||
|
"register_desc": "Crea un nuovo account",
|
||||||
|
"registration_disabled_desc": "La registrazione è disabilitata per questa istanza, contatta l'amministratore in caso di problemi.",
|
||||||
|
"enter_details": "Inserisci i tuoi dettagli",
|
||||||
|
"display_name": "Nome visualizzato",
|
||||||
|
"sign_up_agreement": "Registrandoti, accetti i nostri <0>Termini di Servizio</0> e la <1>Privacy Policy</1>.",
|
||||||
|
"need_help": "Hai bisogno di aiuto?",
|
||||||
|
"get_in_touch": "Contattaci",
|
||||||
|
"already_registered": "Hai già un account?",
|
||||||
|
"deleting_selections": "Eliminazione delle selezioni in corso...",
|
||||||
|
"links_deleted": "{{count}} Link eliminati.",
|
||||||
|
"link_deleted": "1 Link eliminato.",
|
||||||
|
"links_selected": "{{count}} Link selezionati",
|
||||||
|
"link_selected": "1 Link selezionato",
|
||||||
|
"nothing_selected": "Nessuna selezione",
|
||||||
|
"edit": "Modifica",
|
||||||
|
"delete": "Elimina",
|
||||||
|
"nothing_found": "Nessun risultato trovato.",
|
||||||
|
"redirecting_to_stripe": "Reindirizzamento a Stripe...",
|
||||||
|
"subscribe_title": "Abbonati a Linkwarden!",
|
||||||
|
"subscribe_desc": "Sarai reindirizzato a Stripe, non esitare a contattarci a <0>support@linkwarden.app</0> in caso di problemi.",
|
||||||
|
"monthly": "Mensile",
|
||||||
|
"yearly": "Annuale",
|
||||||
|
"discount_percent": "{{percent}}% di sconto",
|
||||||
|
"billed_monthly": "Fatturato mensilmente",
|
||||||
|
"billed_yearly": "Fatturato annualmente",
|
||||||
|
"total": "Totale",
|
||||||
|
"total_annual_desc": "Prova gratuita di {{count}} giorni, poi ${{annualPrice}} all'anno",
|
||||||
|
"total_monthly_desc": "Prova gratuita di {{count}} giorni, poi ${{monthlyPrice}} al mese",
|
||||||
|
"plus_tax": "+ IVA se applicabile",
|
||||||
|
"complete_subscription": "Completa Abbonamento",
|
||||||
|
"sign_out": "Esci",
|
||||||
|
"access_tokens": "Token di Accesso",
|
||||||
|
"access_tokens_description": "I Token di Accesso possono essere utilizzati per accedere a Linkwarden da altre app e servizi senza dover fornire il tuo Nome utente e Password.",
|
||||||
|
"new_token": "Nuovo Token di Accesso",
|
||||||
|
"name": "Nome",
|
||||||
|
"created_success": "Creato con successo!",
|
||||||
|
"created": "Creato",
|
||||||
|
"expires": "Scade",
|
||||||
|
"accountSettings": "Impostazioni Account",
|
||||||
|
"language": "Lingua",
|
||||||
|
"profile_photo": "Foto Profilo",
|
||||||
|
"upload_new_photo": "Carica una nuova foto...",
|
||||||
|
"remove_photo": "Rimuovi Foto",
|
||||||
|
"make_profile_private": "Rendi il profilo privato",
|
||||||
|
"profile_privacy_info": "Questo limiterà chi può trovarti e aggiungerti a nuove Collezioni.",
|
||||||
|
"whitelisted_users": "Utenti nella lista bianca",
|
||||||
|
"whitelisted_users_info": "Per favore fornisci il Nome utente degli utenti a cui desideri concedere la visibilità del tuo profilo. Separati da virgola.",
|
||||||
|
"whitelisted_users_placeholder": "Il tuo profilo è nascosto a tutti in questo momento...",
|
||||||
|
"save_changes": "Salva Modifiche",
|
||||||
|
"import_export": "Importa & Esporta",
|
||||||
|
"import_data": "Importa i tuoi dati da altre piattaforme.",
|
||||||
|
"download_data": "Scarica i tuoi dati istantaneamente.",
|
||||||
|
"export_data": "Esporta Dati",
|
||||||
|
"delete_account": "Elimina Account",
|
||||||
|
"delete_account_warning": "Questo eliminerà permanentemente TUTTI i Link, le Collezioni, i Tag e i dati archiviati di tua proprietà.",
|
||||||
|
"cancel_subscription_notice": "Cancellerà anche il tuo abbonamento.",
|
||||||
|
"account_deletion_page": "Pagina di eliminazione dell'account",
|
||||||
|
"applying_settings": "Applicazione delle impostazioni in corso...",
|
||||||
|
"settings_applied": "Impostazioni Applicate!",
|
||||||
|
"email_change_request": "Richiesta di cambio email inviata. Per favore verifica il nuovo indirizzo email.",
|
||||||
|
"image_upload_size_error": "Per favore seleziona un file PNG o JPEG di dimensioni inferiori a 1MB.",
|
||||||
|
"image_upload_format_error": "Formato file non valido.",
|
||||||
|
"importing_bookmarks": "Importazione dei segnalibri in corso...",
|
||||||
|
"import_success": "Segnalibri importati! Ricaricamento della pagina...",
|
||||||
|
"more_coming_soon": "Altro in arrivo presto!",
|
||||||
|
"billing_settings": "Impostazioni di Fatturazione",
|
||||||
|
"manage_subscription_intro": "Per gestire/cancellare il tuo abbonamento, visita il",
|
||||||
|
"billing_portal": "Portale di Fatturazione",
|
||||||
|
"help_contact_intro": "Se hai ancora bisogno di aiuto o hai riscontrato problemi, non esitare a contattarci a:",
|
||||||
|
"fill_required_fields": "Per favore compila i campi obbligatori.",
|
||||||
|
"deleting_message": "Eliminazione di tutto in corso, attendere prego...",
|
||||||
|
"delete_warning": "Questo eliminerà permanentemente tutti i Link, le Collezioni, i Tag e i dati archiviati di tua proprietà. Ti disconnetterà anche. Questa azione è irreversibile!",
|
||||||
|
"optional": "Opzionale",
|
||||||
|
"feedback_help": "(ma ci aiuta davvero a migliorare!)",
|
||||||
|
"reason_for_cancellation": "Motivo della cancellazione",
|
||||||
|
"please_specify": "Per favore specifica",
|
||||||
|
"customer_service": "Servizio Clienti",
|
||||||
|
"low_quality": "Bassa Qualità",
|
||||||
|
"missing_features": "Funzionalità Mancanti",
|
||||||
|
"switched_service": "Cambiato Servizio",
|
||||||
|
"too_complex": "Troppo Complesso",
|
||||||
|
"too_expensive": "Troppo Costoso",
|
||||||
|
"unused": "Non Utilizzato",
|
||||||
|
"other": "Altro",
|
||||||
|
"more_information": "Ulteriori informazioni (più dettagli fornisci, più utile sarà)",
|
||||||
|
"feedback_placeholder": "es. Avevo bisogno di una funzionalità che...",
|
||||||
|
"delete_your_account": "Elimina il Tuo Account",
|
||||||
|
"change_password": "Cambia Password",
|
||||||
|
"password_length_error": "Le password devono essere di almeno 8 caratteri.",
|
||||||
|
"applying_changes": "Applicazione in corso...",
|
||||||
|
"password_change_instructions": "Per cambiare la tua password, compila quanto segue. La tua password dovrebbe essere di almeno 8 caratteri.",
|
||||||
|
"old_password": "Vecchia Password",
|
||||||
|
"new_password": "Nuova Password",
|
||||||
|
"preference": "Preferenza",
|
||||||
|
"select_theme": "Seleziona Tema",
|
||||||
|
"dark": "Scuro",
|
||||||
|
"light": "Chiaro",
|
||||||
|
"archive_settings": "Impostazioni di Archiviazione",
|
||||||
|
"formats_to_archive": "Formati per archiviare/preservare le pagine web:",
|
||||||
|
"screenshot": "Screenshot",
|
||||||
|
"pdf": "PDF",
|
||||||
|
"archive_org_snapshot": "Snapshot di Archive.org",
|
||||||
|
"link_settings": "Impostazioni Link",
|
||||||
|
"prevent_duplicate_links": "Previeni link duplicati",
|
||||||
|
"clicking_on_links_should": "Cliccando sui Link si dovrebbe:",
|
||||||
|
"open_original_content": "Aprire il contenuto originale",
|
||||||
|
"open_pdf_if_available": "Aprire PDF, se disponibile",
|
||||||
|
"open_readable_if_available": "Aprire versione leggibile, se disponibile",
|
||||||
|
"open_screenshot_if_available": "Aprire Screenshot, se disponibile",
|
||||||
|
"open_webpage_if_available": "Aprire copia della pagina web, se disponibile",
|
||||||
|
"tag_renamed": "Tag rinominato!",
|
||||||
|
"tag_deleted": "Tag eliminato!",
|
||||||
|
"rename_tag": "Rinomina Tag",
|
||||||
|
"delete_tag": "Elimina Tag",
|
||||||
|
"list_created_with_linkwarden": "Lista creata con Linkwarden",
|
||||||
|
"by_author": "Di {{author}}.",
|
||||||
|
"by_author_and_other": "Di {{author}} e {{count}} altro.",
|
||||||
|
"by_author_and_others": "Di {{author}} e {{count}} altri.",
|
||||||
|
"search_count_link": "Cerca {{count}} Link",
|
||||||
|
"search_count_links": "Cerca {{count}} Links",
|
||||||
|
"collection_is_empty": "Questa Collezione è vuota...",
|
||||||
|
"all_links": "Tutti i Link",
|
||||||
|
"all_links_desc": "Link da ogni Collezione",
|
||||||
|
"you_have_not_added_any_links": "Non hai ancora creato alcun Link",
|
||||||
|
"collections_you_own": "Collezioni di tua proprietà",
|
||||||
|
"new_collection": "Nuova Collezione",
|
||||||
|
"other_collections": "Altre Collezioni",
|
||||||
|
"other_collections_desc": "Collezioni condivise di cui sei membro",
|
||||||
|
"showing_count_results": "Mostrati {{count}} risultati",
|
||||||
|
"showing_count_result": "Mostrato {{count}} risultato",
|
||||||
|
"edit_collection_info": "Modifica Info Collezione",
|
||||||
|
"share_and_collaborate": "Condividi e Collabora",
|
||||||
|
"view_team": "Visualizza Team",
|
||||||
|
"team": "Team",
|
||||||
|
"create_subcollection": "Crea Sotto-Collezione",
|
||||||
|
"delete_collection": "Elimina Collezione",
|
||||||
|
"leave_collection": "Lascia Collezione",
|
||||||
|
"email_verified_signing_out": "Email verificata. Disconnessione in corso...",
|
||||||
|
"invalid_token": "Token non valido.",
|
||||||
|
"sending_password_recovery_link": "Invio del link per il recupero della password in corso...",
|
||||||
|
"please_fill_all_fields": "Per favore compila tutti i campi.",
|
||||||
|
"password_updated": "Password Aggiornata!",
|
||||||
|
"reset_password": "Reimposta Password",
|
||||||
|
"enter_email_for_new_password": "Inserisci la tua email per inviarti un link per creare una nuova password.",
|
||||||
|
"update_password": "Aggiorna Password",
|
||||||
|
"password_successfully_updated": "La tua password è stata aggiornata con successo.",
|
||||||
|
"user_already_member": "L'utente esiste già.",
|
||||||
|
"you_are_already_collection_owner": "Sei già il proprietario della collezione.",
|
||||||
|
"date_newest_first": "Data (Più recente prima)",
|
||||||
|
"date_oldest_first": "Data (Più vecchio prima)",
|
||||||
|
"name_az": "Nome (A-Z)",
|
||||||
|
"name_za": "Nome (Z-A)",
|
||||||
|
"description_az": "Descrizione (A-Z)",
|
||||||
|
"description_za": "Descrizione (Z-A)",
|
||||||
|
"all_rights_reserved": "© {{date}} <0>Linkwarden</0>. Tutti i diritti riservati.",
|
||||||
|
"you_have_no_collections": "Non hai Collezioni...",
|
||||||
|
"you_have_no_tags": "Non hai Tag...",
|
||||||
|
"cant_change_collection_you_dont_own": "Non puoi apportare modifiche a una collezione di cui non sei proprietario.",
|
||||||
|
"account": "Account",
|
||||||
|
"billing": "Fatturazione",
|
||||||
|
"linkwarden_version": "Linkwarden {{version}}",
|
||||||
|
"help": "Aiuto",
|
||||||
|
"github": "GitHub",
|
||||||
|
"twitter": "Twitter",
|
||||||
|
"mastodon": "Mastodon",
|
||||||
|
"link_preservation_in_queue": "La preservazione del Link è attualmente in coda",
|
||||||
|
"check_back_later": "Per favore controlla più tardi per vedere il risultato",
|
||||||
|
"there_are_more_formats": "Ci sono altri formati preservati in coda",
|
||||||
|
"settings": "Impostazioni",
|
||||||
|
"switch_to": "Passa a {{theme}}",
|
||||||
|
"logout": "Esci",
|
||||||
|
"start_journey": "Inizia il tuo viaggio creando un nuovo Link!",
|
||||||
|
"create_new_link": "Crea Nuovo Link",
|
||||||
|
"new_link": "Nuovo Link",
|
||||||
|
"create_new": "Crea Nuovo...",
|
||||||
|
"pwa_install_prompt": "Installa Linkwarden sulla tua schermata iniziale per un accesso più rapido e un'esperienza migliore. <0>Scopri di più</0>",
|
||||||
|
"full_content": "Contenuto Completo",
|
||||||
|
"slower": "Più lento",
|
||||||
|
"new_version_announcement": "Scopri le novità in <0>Linkwarden {{version}}!</0>",
|
||||||
|
"creating": "Creazione in corso...",
|
||||||
|
"upload_file": "Carica File",
|
||||||
|
"file": "File",
|
||||||
|
"file_types": "PDF, PNG, JPG (Fino a {{size}} MB)",
|
||||||
|
"description": "Descrizione",
|
||||||
|
"auto_generated": "Sarà generato automaticamente se non viene fornito nulla.",
|
||||||
|
"example_link": "es. Link di Esempio",
|
||||||
|
"hide": "Nascondi",
|
||||||
|
"more": "Altro",
|
||||||
|
"options": "Opzioni",
|
||||||
|
"description_placeholder": "Note, pensieri, ecc.",
|
||||||
|
"deleting": "Eliminazione in corso...",
|
||||||
|
"token_revoked": "Token Revocato.",
|
||||||
|
"revoke_token": "Revoca Token",
|
||||||
|
"revoke_confirmation": "Sei sicuro di voler revocare questo Token di Accesso? Qualsiasi app o servizio che utilizza questo token non sarà più in grado di accedere a Linkwarden utilizzandolo.",
|
||||||
|
"revoke": "Revoca",
|
||||||
|
"sending_request": "Invio richiesta...",
|
||||||
|
"link_being_archived": "Il Link è in fase di archiviazione...",
|
||||||
|
"preserved_formats": "Formati Preservati",
|
||||||
|
"available_formats": "I seguenti formati sono disponibili per questo link:",
|
||||||
|
"readable": "Leggibile",
|
||||||
|
"preservation_in_queue": "La preservazione del Link è in coda",
|
||||||
|
"view_latest_snapshot": "Visualizza l'ultimo snapshot su archive.org",
|
||||||
|
"refresh_preserved_formats": "Aggiorna Formati Preservati",
|
||||||
|
"this_deletes_current_preservations": "Questo elimina le preservazioni attuali",
|
||||||
|
"create_new_user": "Crea Nuovo Utente",
|
||||||
|
"placeholder_johnny": "Johnny",
|
||||||
|
"placeholder_email": "johnny@esempio.com",
|
||||||
|
"placeholder_john": "john",
|
||||||
|
"user_created": "Utente Creato!",
|
||||||
|
"fill_all_fields_error": "Per favore compila tutti i campi.",
|
||||||
|
"password_change_note": "<0>Nota:</0> Assicurati di informare l'utente che deve cambiare la propria password.",
|
||||||
|
"create_user": "Crea Utente",
|
||||||
|
"creating_token": "Creazione Token in corso...",
|
||||||
|
"token_created": "Token Creato!",
|
||||||
|
"access_token_created": "Token di Accesso Creato",
|
||||||
|
"token_creation_notice": "Il tuo nuovo token è stato creato. Per favore copialo e conservalo in un luogo sicuro. Non sarai in grado di vederlo di nuovo.",
|
||||||
|
"copied_to_clipboard": "Copiato negli appunti!",
|
||||||
|
"copy_to_clipboard": "Copia negli Appunti",
|
||||||
|
"create_access_token": "Crea un Token di Accesso",
|
||||||
|
"expires_in": "Scade tra",
|
||||||
|
"token_name_placeholder": "es. Per la scorciatoia iOS",
|
||||||
|
"create_token": "Crea Token di Accesso",
|
||||||
|
"7_days": "7 Giorni",
|
||||||
|
"30_days": "30 Giorni",
|
||||||
|
"60_days": "60 Giorni",
|
||||||
|
"90_days": "90 Giorni",
|
||||||
|
"no_expiration": "Nessuna Scadenza",
|
||||||
|
"creating_link": "Creazione link in corso...",
|
||||||
|
"link_created": "Link creato!",
|
||||||
|
"link_name_placeholder": "Sarà generato automaticamente se lasciato vuoto.",
|
||||||
|
"link_url_placeholder": "es. http://esempio.com/",
|
||||||
|
"link_description_placeholder": "Note, pensieri, ecc.",
|
||||||
|
"more_options": "Più Opzioni",
|
||||||
|
"hide_options": "Nascondi Opzioni",
|
||||||
|
"create_link": "Crea Link",
|
||||||
|
"new_sub_collection": "Nuova Sotto-Collezione",
|
||||||
|
"for_collection": "Per {{name}}",
|
||||||
|
"create_new_collection": "Crea una Nuova Collezione",
|
||||||
|
"color": "Colore",
|
||||||
|
"reset": "Ripristina",
|
||||||
|
"collection_name_placeholder": "es. Collezione di Esempio",
|
||||||
|
"collection_description_placeholder": "Lo scopo di questa Collezione...",
|
||||||
|
"create_collection_button": "Crea Collezione",
|
||||||
|
"password_change_warning": "Per favore conferma la tua password prima di cambiare il tuo indirizzo email.",
|
||||||
|
"stripe_update_note": "L'aggiornamento di questo campo cambierà anche la tua email di fatturazione su Stripe.",
|
||||||
|
"sso_will_be_removed_warning": "Se cambi il tuo indirizzo email, tutte le connessioni SSO {{service}} esistenti verranno rimosse.",
|
||||||
|
"old_email": "Vecchia Email",
|
||||||
|
"new_email": "Nuova Email",
|
||||||
|
"confirm": "Conferma",
|
||||||
|
"edit_link": "Modifica Link",
|
||||||
|
"updating": "Aggiornamento in corso...",
|
||||||
|
"updated": "Aggiornato!",
|
||||||
|
"placeholder_example_link": "es. Link di Esempio",
|
||||||
|
"make_collection_public": "Rendi la Collezione Pubblica",
|
||||||
|
"make_collection_public_checkbox": "Rendi questa una collezione pubblica",
|
||||||
|
"make_collection_public_desc": "Questo permetterà a chiunque di visualizzare questa collezione e i suoi utenti.",
|
||||||
|
"sharable_link_guide": "Link Condivisibile (Clicca per copiare)",
|
||||||
|
"copied": "Copiato!",
|
||||||
|
"members": "Membri",
|
||||||
|
"members_username_placeholder": "Nome utente (senza '@')",
|
||||||
|
"owner": "Proprietario",
|
||||||
|
"admin": "Amministratore",
|
||||||
|
"contributor": "Collaboratore",
|
||||||
|
"viewer": "Visualizzatore",
|
||||||
|
"viewer_desc": "Accesso in sola lettura",
|
||||||
|
"contributor_desc": "Può visualizzare e creare Link",
|
||||||
|
"admin_desc": "Accesso completo a tutti i Link",
|
||||||
|
"remove_member": "Rimuovi Membro",
|
||||||
|
"placeholder_example_collection": "es. Collezione di Esempio",
|
||||||
|
"placeholder_collection_purpose": "Lo scopo di questa Collezione...",
|
||||||
|
"deleting_user": "Eliminazione in corso...",
|
||||||
|
"user_deleted": "Utente Eliminato.",
|
||||||
|
"delete_user": "Elimina Utente",
|
||||||
|
"confirm_user_deletion": "Sei sicuro di voler rimuovere questo utente?",
|
||||||
|
"irreversible_action_warning": "Questa azione è irreversibile!",
|
||||||
|
"delete_confirmation": "Elimina, so cosa sto facendo",
|
||||||
|
"delete_link": "Elimina Link",
|
||||||
|
"deleted": "Eliminato.",
|
||||||
|
"link_deletion_confirmation_message": "Sei sicuro di voler eliminare questo Link?",
|
||||||
|
"warning": "Attenzione",
|
||||||
|
"irreversible_warning": "Questa azione è irreversibile!",
|
||||||
|
"shift_key_tip": "Tieni premuto il tasto Shift mentre clicchi su 'Elimina' per evitare questa conferma in futuro.",
|
||||||
|
"deleting_collection": "Eliminazione in corso...",
|
||||||
|
"collection_deleted": "Collezione Eliminata.",
|
||||||
|
"confirm_deletion_prompt": "Per confermare, digita \"{{name}}\" nella casella sottostante:",
|
||||||
|
"type_name_placeholder": "Digita \"{{name}}\" Qui.",
|
||||||
|
"deletion_warning": "L'eliminazione di questa collezione cancellerà permanentemente tutti i suoi contenuti e diventerà inaccessibile a tutti, inclusi i membri con accesso precedente.",
|
||||||
|
"leave_prompt": "Clicca il pulsante sottostante per lasciare la collezione corrente.",
|
||||||
|
"leave": "Lascia",
|
||||||
|
"edit_links": "Modifica {{count}} Link",
|
||||||
|
"move_to_collection": "Sposta nella Collezione",
|
||||||
|
"add_tags": "Aggiungi Tag",
|
||||||
|
"remove_previous_tags": "Rimuovi tag precedenti",
|
||||||
|
"delete_links": "Elimina {{count}} Link",
|
||||||
|
"links_deletion_confirmation_message": "Sei sicuro di voler eliminare {{count}} Link? ",
|
||||||
|
"warning_irreversible": "Attenzione: Questa azione è irreversibile!",
|
||||||
|
"shift_key_instruction": "Tieni premuto il tasto 'Shift' mentre clicchi su 'Elimina' per evitare questa conferma in futuro.",
|
||||||
|
"link_selection_error": "Non hai il permesso di modificare o eliminare questo elemento.",
|
||||||
|
"no_description": "Nessuna descrizione fornita.",
|
||||||
|
"applying": "Applicazione in corso...",
|
||||||
|
"unpin": "Rimuovi fissaggio",
|
||||||
|
"pin_to_dashboard": "Fissa alla Dashboard",
|
||||||
|
"show_link_details": "Mostra Dettagli Link",
|
||||||
|
"hide_link_details": "Nascondi Dettagli Link",
|
||||||
|
"link_pinned": "Link Fissato!",
|
||||||
|
"link_unpinned": "Fissaggio Link Rimosso!",
|
||||||
|
"webpage": "Pagina web",
|
||||||
|
"server_administration": "Amministrazione Server",
|
||||||
|
"all_collections": "Tutte le Collezioni",
|
||||||
|
"dashboard": "Dashboard"
|
||||||
|
}
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
// [Optional, but recommended]
|
|
||||||
|
|
||||||
// We decided that the "name" field should be the auto-generated field instead of the "description" field, so we need to
|
|
||||||
// move the data from the "description" field to the "name" field for links that have an empty name.
|
|
||||||
|
|
||||||
// This script is meant to be run only once.
|
|
||||||
|
|
||||||
// Run the script with `node scripts/migration/descriptionToName.js`
|
|
||||||
|
|
||||||
const { PrismaClient } = require("@prisma/client");
|
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
console.log("Starting...");
|
|
||||||
|
|
||||||
const count = await prisma.link.count({
|
|
||||||
where: {
|
|
||||||
name: "",
|
|
||||||
description: {
|
|
||||||
not: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(
|
|
||||||
`Applying the changes to ${count} ${
|
|
||||||
count == 1 ? "link" : "links"
|
|
||||||
} in 10 seconds...`
|
|
||||||
);
|
|
||||||
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 10000));
|
|
||||||
|
|
||||||
console.log("Applying the changes...");
|
|
||||||
|
|
||||||
const links = await prisma.link.findMany({
|
|
||||||
where: {
|
|
||||||
name: "",
|
|
||||||
description: {
|
|
||||||
not: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
description: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const link of links) {
|
|
||||||
await prisma.link.update({
|
|
||||||
where: {
|
|
||||||
id: link.id,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
name: link.description,
|
|
||||||
description: "",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("Done!");
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
.catch((e) => {
|
|
||||||
throw e;
|
|
||||||
})
|
|
||||||
.finally(async () => {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
});
|
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
// Run the script with `node scripts/migration/v2.6.1/index.js`
|
||||||
|
// Docker users can run the script with `docker exec -it CONTAINER_ID /bin/bash -c 'node scripts/migration/v2.6.1/index.js'`
|
||||||
|
|
||||||
|
// There are two parts to this script:
|
||||||
|
|
||||||
|
// Firstly we decided that the "name" field should be the auto-generated field instead of the "description" field, so we need to
|
||||||
|
// move the data from the "description" field to the "name" field for links that have an empty name.
|
||||||
|
|
||||||
|
// Secondly it looks for every link and checks if the pdf/screenshot exist in the filesystem.
|
||||||
|
// If they do, it updates the link with the path in the db.
|
||||||
|
// If they don't, it passes.
|
||||||
|
|
||||||
|
const { S3 } = require("@aws-sdk/client-s3");
|
||||||
|
const { PrismaClient } = require("@prisma/client");
|
||||||
|
const { existsSync } = require("fs");
|
||||||
|
const util = require("util");
|
||||||
|
|
||||||
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
|
const STORAGE_FOLDER = process.env.STORAGE_FOLDER || "data";
|
||||||
|
|
||||||
|
const s3Client =
|
||||||
|
process.env.SPACES_ENDPOINT &&
|
||||||
|
process.env.SPACES_REGION &&
|
||||||
|
process.env.SPACES_KEY &&
|
||||||
|
process.env.SPACES_SECRET
|
||||||
|
? new S3({
|
||||||
|
forcePathStyle: false,
|
||||||
|
endpoint: process.env.SPACES_ENDPOINT,
|
||||||
|
region: process.env.SPACES_REGION,
|
||||||
|
credentials: {
|
||||||
|
accessKeyId: process.env.SPACES_KEY,
|
||||||
|
secretAccessKey: process.env.SPACES_SECRET,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
async function checkFileExistence(path) {
|
||||||
|
if (s3Client) {
|
||||||
|
// One millisecond delay to avoid rate limiting
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 1));
|
||||||
|
|
||||||
|
const bucketParams = {
|
||||||
|
Bucket: process.env.SPACES_BUCKET_NAME,
|
||||||
|
Key: path,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const headObjectAsync = util.promisify(
|
||||||
|
s3Client.headObject.bind(s3Client)
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await headObjectAsync(bucketParams);
|
||||||
|
return true;
|
||||||
|
} catch (err) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("Error:", err);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
if (existsSync(STORAGE_FOLDER + "/" + path)) {
|
||||||
|
return true;
|
||||||
|
} else return false;
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
console.log("Starting... Please do not interrupt the process.");
|
||||||
|
|
||||||
|
const linksWithoutName = await prisma.link.findMany({
|
||||||
|
where: {
|
||||||
|
name: "",
|
||||||
|
description: {
|
||||||
|
not: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
description: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const link of linksWithoutName) {
|
||||||
|
await prisma.link.update({
|
||||||
|
where: {
|
||||||
|
id: link.id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
name: link.description,
|
||||||
|
description: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const links = await prisma.link.findMany({
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
collectionId: true,
|
||||||
|
image: true,
|
||||||
|
pdf: true,
|
||||||
|
readable: true,
|
||||||
|
monolith: true,
|
||||||
|
},
|
||||||
|
orderBy: { id: "asc" },
|
||||||
|
});
|
||||||
|
|
||||||
|
// PDFs
|
||||||
|
for (let link of links) {
|
||||||
|
const path = `archives/${link.collectionId}/${link.id}.pdf`;
|
||||||
|
|
||||||
|
const res = await checkFileExistence(path);
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
await prisma.link.update({
|
||||||
|
where: { id: link.id },
|
||||||
|
data: { pdf: path },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Indexing the PDF for link:", link.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Screenshots (PNGs)
|
||||||
|
for (let link of links) {
|
||||||
|
const path = `archives/${link.collectionId}/${link.id}.png`;
|
||||||
|
|
||||||
|
const res = await checkFileExistence(path);
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
await prisma.link.update({
|
||||||
|
where: { id: link.id },
|
||||||
|
data: { image: path },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Indexing the PNG for link:", link.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Screenshots (JPEGs)
|
||||||
|
for (let link of links) {
|
||||||
|
const path = `archives/${link.collectionId}/${link.id}.jpeg`;
|
||||||
|
|
||||||
|
const res = await checkFileExistence(path);
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
await prisma.link.update({
|
||||||
|
where: { id: link.id },
|
||||||
|
data: { image: path },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Indexing the JPEG for link:", link.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
await prisma.$disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((e) => {
|
||||||
|
console.error(e);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user