fix: Correct user on documents in deleted collection (#6116)
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user