diff --git a/data/document.go b/data/document.go index 2888f862..44706213 100644 --- a/data/document.go +++ b/data/document.go @@ -15,6 +15,7 @@ type AccountData struct { } type Document struct { + // TODO: ensure that every operation on Document is synchronized thread threadmodels.Thread stateProvider InitialStateProvider accountData *AccountData @@ -99,6 +100,14 @@ func (d *Document) Create(payload *CreateChangePayload) error { if err != nil { return err } + + if aclChange.AclData != nil { + // we can apply change right away without going through builder, because + err = d.docContext.aclState.ApplyChange(payload.Id, aclChange) + if err != nil { + return err + } + } d.docContext.fullTree.AddFast(ch) err = d.thread.AddChange(&threadmodels.RawChange{ @@ -157,6 +166,7 @@ func (d *Document) Update(changes ...*threadmodels.RawChange) (DocumentState, Up break } + // TODO: we should still check if the user making those changes are able to write using "aclState" // decrypting everything, because we have no new keys for _, ch := range treeChanges { if ch.Content.GetChangesData() != nil { diff --git a/data/documentcontext.go b/data/documentcontext.go index 5d723e9a..4acfb76f 100644 --- a/data/documentcontext.go +++ b/data/documentcontext.go @@ -1,7 +1,7 @@ package data type documentContext struct { - aclTree *Tree + aclTree *Tree // TODO: remove it, because we don't use it fullTree *Tree aclState *ACLState docState DocumentState diff --git a/data/documentstatebuilder.go b/data/documentstatebuilder.go index c0cb55a9..3c9b0ea9 100644 --- a/data/documentstatebuilder.go +++ b/data/documentstatebuilder.go @@ -66,6 +66,7 @@ func (d *documentStateBuilder) build() (s DocumentState, err error) { func (d *documentStateBuilder) appendFrom(fromId string, init DocumentState) (s DocumentState, err error) { // TODO: we should do something like state copy probably s = init + // TODO: we should have the same logic as in ACLStateBuilder, that means we should either pass in both methods state from the outside or save the state inside the builder d.tree.Iterate(fromId, func(c *Change) (isContinue bool) { if c.Id == fromId { return true