mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-11 18:20:28 +09:00
Fix change validator
This commit is contained in:
parent
07b17491cb
commit
cf63d29b42
3 changed files with 7 additions and 2 deletions
|
@ -15,7 +15,7 @@ import (
|
|||
"hash/fnv"
|
||||
)
|
||||
|
||||
var log = logger.NewNamed("acllist")
|
||||
var log = logger.NewNamed("acllist").Sugar()
|
||||
|
||||
var ErrNoSuchUser = errors.New("no such user")
|
||||
var ErrFailedToDecrypt = errors.New("failed to decrypt key")
|
||||
|
@ -77,6 +77,7 @@ func (st *ACLState) UserReadKeys() map[uint64]*symmetric.Key {
|
|||
func (st *ACLState) PermissionsAtRecord(id string, identity string) (UserPermissionPair, error) {
|
||||
permissions, ok := st.permissionsAtRecord[id]
|
||||
if !ok {
|
||||
log.Errorf("missing record at id %s", id)
|
||||
return UserPermissionPair{}, ErrNoSuchRecord
|
||||
}
|
||||
|
||||
|
@ -135,6 +136,7 @@ func (st *ACLState) applyChangeAndUpdate(recordWrapper *Record) (err error) {
|
|||
permissions = append(permissions, permission)
|
||||
}
|
||||
st.permissionsAtRecord[recordWrapper.Id] = permissions
|
||||
log.Infof("adding permissions at record %s", recordWrapper.Id)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
|
||||
"go.uber.org/zap"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
@ -98,6 +99,8 @@ func buildWithACLStateBuilder(builder *aclStateBuilder, storage storage.ListStor
|
|||
indexes[records[len(records)/2].Id] = len(records) / 2
|
||||
}
|
||||
|
||||
log.With(zap.String("head id", records[len(records)-1].Id), zap.String("list id", id)).
|
||||
Info("building acl tree")
|
||||
state, err := builder.Build(records)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -26,7 +26,7 @@ func (v *docTreeValidator) ValidateTree(tree *Tree, aclList list.ACLList) (err e
|
|||
|
||||
tree.Iterate(tree.RootId(), func(c *Change) (isContinue bool) {
|
||||
// checking if the user could write
|
||||
perm, err = state.PermissionsAtRecord(c.Id, c.Content.Identity)
|
||||
perm, err = state.PermissionsAtRecord(c.Content.AclHeadId, c.Content.Identity)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue