fix: Long collection description prevents import (#3847)

* fix: Long collection description prevents import
fix: Parallelize attachment upload during import

* fix: Improve Notion image import matching

* chore: Bump JSZIP (perf)

* fix: Allow redirect from /doc/<id> to canonical url

* fix: Importing document with only title duplicates title in body
This commit is contained in:
Tom Moor
2022-07-24 09:37:20 +01:00
committed by GitHub
parent 4f537c7578
commit 7ae892fe06
9 changed files with 70 additions and 31 deletions

View File

@@ -1,4 +1,5 @@
import { truncate } from "lodash";
import { CollectionValidation } from "@shared/validations";
import attachmentCreator from "@server/commands/attachmentCreator";
import documentCreator from "@server/commands/documentCreator";
import { sequelize } from "@server/database/sequelize";
@@ -206,22 +207,26 @@ export default abstract class ImportTask extends BaseTask<Props> {
const ip = user.lastActiveIp || undefined;
// Attachments
for (const item of data.attachments) {
const attachment = await attachmentCreator({
source: "import",
id: item.id,
name: item.name,
type: item.mimeType,
buffer: item.buffer,
user,
ip,
transaction,
});
attachments.set(item.id, attachment);
}
await Promise.all(
data.attachments.map(async (item) => {
Logger.debug("task", `ImportTask persisting attachment ${item.id}`);
const attachment = await attachmentCreator({
source: "import",
id: item.id,
name: item.name,
type: item.mimeType,
buffer: item.buffer,
user,
ip,
transaction,
});
attachments.set(item.id, attachment);
})
);
// Collections
for (const item of data.collections) {
Logger.debug("task", `ImportTask persisting collection ${item.id}`);
let description = item.description;
if (description) {
@@ -258,7 +263,9 @@ export default abstract class ImportTask extends BaseTask<Props> {
},
defaults: {
id: item.id,
description,
description: truncate(description, {
length: CollectionValidation.maxDescriptionLength,
}),
createdById: fileOperation.userId,
permission: "read_write",
},
@@ -307,6 +314,7 @@ export default abstract class ImportTask extends BaseTask<Props> {
// Documents
for (const item of data.documents) {
Logger.debug("task", `ImportTask persisting document ${item.id}`);
let text = item.text;
// Check all of the attachments we've created against urls in the text