Add content mutation norm editor socket endpoint
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Garrett Mills 2021-01-31 10:26:32 -06:00
parent 93d192d69c
commit 2c105fe350
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

View File

@ -93,6 +93,15 @@ class NormEditorGroup {
} }
} }
blast_content_mutation(mutation, exclude_conn_id) {
const conns = Object.values(this.connections)
for ( const conn of conns ) {
if ( conn.id === exclude_conn_id ) continue;
conn._request('applyRemoteContentMutation', { mutation })
}
}
set_member_selection(conn, selection) { set_member_selection(conn, selection) {
const session = this.session(conn) const session = this.session(conn)
if ( session ) { if ( session ) {
@ -198,6 +207,20 @@ class NormEditorController extends SocketController {
) )
} }
broadcast_content_mutation(transaction, socket) {
const editor_group = this._get_editor_group_or_fail(transaction)
if ( !editor_group ) return;
if ( transaction.incoming.data.path.toLowerCase().startsWith('body@') ) {
return transaction.status(200).send()
}
console.log('mutation', transaction.incoming.data)
editor_group.blast_content_mutation(transaction.incoming.data, transaction.cm.id)
transaction.status(200).send()
}
async join_editor_group(transaction, socket) { async join_editor_group(transaction, socket) {
// FIXME support versioning // FIXME support versioning
const Page = this.models.get('api:Page') const Page = this.models.get('api:Page')