Files
outline/server/queues/tasks/FlattenDocumentStateTask.ts
Tom Moor d29bd1c788 feat: Flatten collaborative state of large documents
Replace edit history in large collaborative state with fresh state once a
document is idle with no open sessions, and when state is over the maximum
length on save. Each replacement increments a state generation that is part of
the collaboration room name, so old state never merges into the new state.
2026-11-13 22:52:37 -05:00

25 lines
826 B
TypeScript

import documentStateFlattener from "@server/commands/documentStateFlattener";
import { BaseTask } from "./base/BaseTask";
interface Props {
/** The document ID to flatten. */
documentId: string;
/** The user that the notification to the collaboration server is from. */
actorId: string;
}
/**
* Flattens the collaborative state of a document after its last collaboration
* session closes. See documentStateFlattener. One job is queued per document,
* it checks the conditions at the time it runs.
*/
export default class FlattenDocumentStateTask extends BaseTask<Props> {
public async perform({ documentId, actorId }: Props) {
await documentStateFlattener({ documentId, actorId, since: new Date() });
}
protected jobId({ documentId }: Props) {
return `flatten-document-state:${documentId}`;
}
}