fix: Correct user on documents in deleted collection (#6116)

This commit is contained in:
Tom Moor
2023-11-05 09:43:38 -05:00
committed by GitHub
parent c76aa845f4
commit 7c319c17c6
4 changed files with 26 additions and 38 deletions

View File

@@ -1,5 +1,5 @@
import { Transaction } from "sequelize";
import { Collection, Event, User } from "@server/models";
import { Transaction, Op } from "sequelize";
import { Collection, Document, Event, User } from "@server/models";
type Props = {
/** The collection to delete */
@@ -20,6 +20,23 @@ export default async function collectionDestroyer({
}: Props) {
await collection.destroy({ transaction });
await Document.update(
{
lastModifiedById: user.id,
deletedAt: new Date(),
},
{
transaction,
where: {
teamId: collection.teamId,
collectionId: collection.id,
archivedAt: {
[Op.is]: null,
},
},
}
);
await Event.create(
{
name: "collections.delete",