fix: Can't un-publish docs with archived children. closes #6408

This commit is contained in:
Tom Moor
2024-01-20 21:34:48 -05:00
parent 2f2113adb8
commit 4e8fe75368
3 changed files with 30 additions and 5 deletions

View File

@@ -859,12 +859,9 @@ class Document extends ParanoidModel<
const parent = await (this.constructor as typeof Document).findOne({
where: {
id: this.parentDocumentId,
archivedAt: {
[Op.is]: null,
},
},
});
if (!parent) {
if (parent?.isDraft || !parent?.isActive) {
this.parentDocumentId = null;
}
}