mirror of
https://github.com/outline/outline.git
synced 2026-11-21 21:44:30 +03:00
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.
25 lines
826 B
TypeScript
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}`;
|
|
}
|
|
}
|