mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
42959d66db
* wip * Implementation complete * tidying * test * Address feedback * Remove duplicative retry logic from UpdateDocumentsPopularityScoreTask. Now that we're split across many runs this is not neccessary * Refactor to subclass, config to instance * Refactor BaseTask to named export * fix: Missing partition * tsc * Feedback
30 lines
758 B
TypeScript
30 lines
758 B
TypeScript
import { Op } from "sequelize";
|
|
import documentPermanentDeleter from "@server/commands/documentPermanentDeleter";
|
|
import { Document } from "@server/models";
|
|
import { BaseTask } from "./base/BaseTask";
|
|
|
|
type Props = {
|
|
documentIds: string[];
|
|
};
|
|
|
|
export default class EmptyTrashTask extends BaseTask<Props> {
|
|
public async perform({ documentIds }: Props) {
|
|
if (!documentIds.length) {
|
|
return;
|
|
}
|
|
const documents = await Document.unscoped().findAll({
|
|
where: {
|
|
id: {
|
|
[Op.in]: documentIds,
|
|
},
|
|
// for safety, ensure the documents are in soft-delete state.
|
|
deletedAt: {
|
|
[Op.ne]: null,
|
|
},
|
|
},
|
|
paranoid: false,
|
|
});
|
|
await documentPermanentDeleter(documents);
|
|
}
|
|
}
|