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

@@ -2,12 +2,19 @@ import teamUpdater from "@server/commands/teamUpdater";
import { Team, User } from "@server/models";
import { sequelize } from "@server/storage/database";
import { Event as TEvent, CollectionEvent } from "@server/types";
import DetachDraftsFromCollectionTask from "../tasks/DetachDraftsFromCollectionTask";
import BaseProcessor from "./BaseProcessor";
export default class CollectionDeletedProcessor extends BaseProcessor {
static applicableEvents: TEvent["name"][] = ["collections.delete"];
async perform(event: CollectionEvent) {
await DetachDraftsFromCollectionTask.schedule({
collectionId: event.collectionId,
actorId: event.actorId,
ip: event.ip,
});
await sequelize.transaction(async (transaction) => {
const team = await Team.findByPk(event.teamId, {
rejectOnEmpty: true,

View File

@@ -1,23 +0,0 @@
import { CollectionEvent, Event } from "@server/types";
import DetachDraftsFromCollectionTask from "../tasks/DetachDraftsFromCollectionTask";
import BaseProcessor from "./BaseProcessor";
export default class CollectionsProcessor extends BaseProcessor {
static applicableEvents: Event["name"][] = ["collections.delete"];
async perform(event: CollectionEvent) {
switch (event.name) {
case "collections.delete":
return this.collectionDeleted(event);
default:
}
}
async collectionDeleted(event: CollectionEvent) {
await DetachDraftsFromCollectionTask.schedule({
collectionId: event.collectionId,
actorId: event.actorId,
ip: event.ip,
});
}
}