OT: filtered rename ops are missing fields

in filterRegistered of ot-server.ts, there’s this code that rewrites rename ops into add or unlink if a doc is being moved from/to somewhere not registered

case 'rename':
    // rename is trickier: we want to send it untouched if the client has
    // both the new and the old parent registered. Otherwise we have
    // to change it either to an add or to an unlink
    if (registeredDocIds[op.oldParentId] &&
        registeredDocIds[op.newParentId]) {
        filteredOpList.ops.push(op);
    }
    else if (registeredDocIds[op.oldParentId]) {
        filteredOpList.ops.push({
            type: 'unlink',
            docId: op.docId
        });
    }
    else if (registeredDocIds[op.newParentId]) {
        filteredOpList.ops.push({
            type: 'add',
            docId: op.docId,
            name: op.newName,
            parentId: op.newParentId
        });
    }
    break;
  • the unlink op for moving a doc to an unregistered parent is missing the parentId field, which is present in normal unlink ops
  • the add op for moving a doc from an unregistered parent is missing the docType field, which is present in normal add ops.

Where this code come from?

it’s from the “watcher” program that runs inside the project container, as a backend for the editor

1 Like