mirror of
https://github.com/outline/outline.git
synced 2026-12-02 09:42:07 +03:00
* 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. * fix: Refuse to load state of another generation and lock editor during reset * Remove excessive tests * fix: Reset rooms on all instances and check state generation during authentication * refactor: Schedule state flattening only for changed rooms, from PersistenceExtension * fix: Refuse API text updates applied to state of an earlier generation
27 lines
868 B
TypeScript
27 lines
868 B
TypeScript
import documentStateFlattener from "@server/commands/documentStateFlattener";
|
|
import type { DocumentEvent, Event } from "@server/types";
|
|
import BaseProcessor from "./BaseProcessor";
|
|
|
|
export default class DocumentStateProcessor extends BaseProcessor {
|
|
static applicableEvents: Event["name"][] = ["documents.update.debounced"];
|
|
|
|
/**
|
|
* Flatten the collaborative state of a document once nobody has edited it
|
|
* for some time, so that users are unlikely to see the reset.
|
|
*
|
|
* @param event the debounced update event.
|
|
* @returns a promise resolving when the event is processed.
|
|
*/
|
|
async perform(event: DocumentEvent) {
|
|
if (event.name !== "documents.update.debounced") {
|
|
return;
|
|
}
|
|
|
|
await documentStateFlattener({
|
|
documentId: event.documentId,
|
|
actorId: event.actorId,
|
|
since: new Date(event.createdAt),
|
|
});
|
|
}
|
|
}
|