chore: Various importer improvements (#6519)
* Handle new Notion export format Clear data on file operation delete * fix: Don't restart development server on html upload * fix: Do not send collection created notifications on bulk import * fix: Avoid parellelizing all uploads at once Move import into one transaction per-collection
This commit is contained in:
@@ -103,7 +103,7 @@ class Attachment extends IdModel<
|
||||
* Get a url that can be used to download a private attachment if the user has a valid session.
|
||||
*/
|
||||
get redirectUrl() {
|
||||
return `/api/attachments.redirect?id=${this.id}`;
|
||||
return Attachment.getRedirectUrl(this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,6 +175,17 @@ class Attachment extends IdModel<
|
||||
return parseInt(result?.[0]?.total ?? "0", 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the redirect URL for a private attachment. Use `attachment.redirectUrl` if you already have
|
||||
* an instance of the attachment.
|
||||
*
|
||||
* @param id The ID of the attachment to get the redirect URL for.
|
||||
* @returns The redirect URL for the attachment.
|
||||
*/
|
||||
static getRedirectUrl(id: string) {
|
||||
return `/api/attachments.redirect?id=${id}`;
|
||||
}
|
||||
|
||||
// associations
|
||||
|
||||
@BelongsTo(() => Team, "teamId")
|
||||
|
||||
@@ -1006,22 +1006,25 @@ class Document extends ParanoidModel<
|
||||
toNavigationNode = async (
|
||||
options?: FindOptions<Document>
|
||||
): Promise<NavigationNode> => {
|
||||
const childDocuments = await (this.constructor as typeof Document)
|
||||
.unscoped()
|
||||
.scope("withoutState")
|
||||
.findAll({
|
||||
where: {
|
||||
teamId: this.teamId,
|
||||
parentDocumentId: this.id,
|
||||
archivedAt: {
|
||||
[Op.is]: null,
|
||||
},
|
||||
publishedAt: {
|
||||
[Op.ne]: null,
|
||||
},
|
||||
},
|
||||
transaction: options?.transaction,
|
||||
});
|
||||
// Checking if the record is new is a performance optimization – new docs cannot have children
|
||||
const childDocuments = this.isNewRecord
|
||||
? []
|
||||
: await (this.constructor as typeof Document)
|
||||
.unscoped()
|
||||
.scope("withoutState")
|
||||
.findAll({
|
||||
where: {
|
||||
teamId: this.teamId,
|
||||
parentDocumentId: this.id,
|
||||
archivedAt: {
|
||||
[Op.is]: null,
|
||||
},
|
||||
publishedAt: {
|
||||
[Op.ne]: null,
|
||||
},
|
||||
},
|
||||
transaction: options?.transaction,
|
||||
});
|
||||
|
||||
const children = await Promise.all(
|
||||
childDocuments.map((child) => child.toNavigationNode(options))
|
||||
|
||||
Reference in New Issue
Block a user