This commit is contained in:
Isaac Wise
2024-07-27 17:41:13 -05:00
parent 4faf389a2b
commit 94be3a7448
34 changed files with 308 additions and 256 deletions
+5 -2
View File
@@ -26,7 +26,7 @@ export default async function exportData(userId: number) {
if (Array.isArray(data)) {
data.forEach((item) => redactIds(item));
} else if (data !== null && typeof data === "object") {
const fieldsToRedact = ['id', 'parentId', 'collectionId', 'ownerId'];
const fieldsToRedact = ["id", "parentId", "collectionId", "ownerId"];
fieldsToRedact.forEach((field) => {
if (field in data) {
@@ -37,7 +37,10 @@ export default async function exportData(userId: number) {
// Recursively call redactIds for each property that is an object or an array
Object.keys(data).forEach((key) => {
const value = (data as any)[key];
if (value !== null && (typeof value === "object" || Array.isArray(value))) {
if (
value !== null &&
(typeof value === "object" || Array.isArray(value))
) {
redactIds(value);
}
});
@@ -63,7 +63,8 @@ async function processBookmarks(
) as Element;
if (collectionName) {
const collectionNameContent = (collectionName.children[0] as TextNode)?.content;
const collectionNameContent = (collectionName.children[0] as TextNode)
?.content;
if (collectionNameContent) {
collectionId = await createCollection(
userId,
@@ -274,4 +275,3 @@ function processNodes(nodes: Node[]) {
nodes.forEach(findAndProcessDL);
return nodes;
}
@@ -84,23 +84,23 @@ export default async function importFromWallabag(
tags:
link.tags && link.tags[0]
? {
connectOrCreate: link.tags.map((tag) => ({
where: {
name_ownerId: {
name: tag.trim(),
ownerId: userId,
},
},
create: {
name: tag.trim(),
owner: {
connect: {
id: userId,
connectOrCreate: link.tags.map((tag) => ({
where: {
name_ownerId: {
name: tag.trim(),
ownerId: userId,
},
},
},
})),
}
create: {
name: tag.trim(),
owner: {
connect: {
id: userId,
},
},
},
})),
}
: undefined,
},
});