feat: Add button to empty trash (#6772)

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Hemachandar
2024-04-16 18:34:56 +05:30
committed by GitHub
parent a5d2752122
commit ef0fb74308
11 changed files with 244 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
import uniq from "lodash/uniq";
import { QueryTypes } from "sequelize";
import { Op, QueryTypes } from "sequelize";
import Logger from "@server/logging/Logger";
import { Document, Attachment } from "@server/models";
import DeleteAttachmentTask from "@server/queues/tasks/DeleteAttachmentTask";
@@ -73,6 +73,21 @@ export default async function documentPermanentDeleter(documents: Document[]) {
);
}
const documentIds = documents.map((document) => document.id);
await Document.update(
{
parentDocumentId: null,
},
{
where: {
parentDocumentId: {
[Op.in]: documentIds,
},
},
paranoid: false,
}
);
return Document.scope("withDrafts").destroy({
where: {
id: documents.map((document) => document.id),