1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

move acl tree files to acl folder

This commit is contained in:
Sergey Cherepanov 2022-07-13 19:17:50 +03:00 committed by Mikhail Iudin
parent de775e95b0
commit d2c9fd4500
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
45 changed files with 65 additions and 67 deletions

View file

@ -1,6 +1,8 @@
package aclchanges
import "github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges/pb"
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges/pb"
)
type Change interface {
ProtoChange() *pb.ACLChange

View file

@ -4,11 +4,10 @@ import (
"bytes"
"errors"
"fmt"
"hash/fnv"
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
"github.com/textileio/go-threads/crypto/symmetric"
"hash/fnv"
)
var ErrNoSuchUser = errors.New("no such user")

View file

@ -2,9 +2,9 @@ package acltree
import (
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
)

View file

@ -1,10 +1,10 @@
package acltree
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread"
"sync"
"github.com/anytypeio/go-anytype-infrastructure-experiments/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/thread"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
)

View file

@ -1,13 +1,12 @@
package acltree
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/testutils/threadbuilder"
"testing"
"github.com/stretchr/testify/assert"
"github.com/anytypeio/go-anytype-infrastructure-experiments/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/testutils/threadbuilder"
)
type mockListener struct{}

View file

@ -2,8 +2,8 @@ package acltree
import (
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread"
"github.com/anytypeio/go-anytype-infrastructure-experiments/thread"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
)

View file

@ -2,10 +2,10 @@ package acltree
import (
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/thread"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread"
"github.com/gogo/protobuf/proto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges/pb"
"github.com/textileio/go-threads/crypto/symmetric"
)

View file

@ -1,8 +1,8 @@
package acltree
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
"github.com/gogo/protobuf/proto"

View file

@ -3,10 +3,10 @@ package acltree
import (
"context"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread"
"time"
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/thread"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
"github.com/gogo/protobuf/proto"
)

View file

@ -2,8 +2,8 @@ package acltree
import (
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
)

View file

@ -1,8 +1,8 @@
package acltree
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/thread"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
)

View file

@ -2,10 +2,10 @@ package acltree
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/testutils/threadbuilder"
"github.com/anytypeio/go-anytype-infrastructure-experiments/thread"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/testutils/threadbuilder"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread"
"github.com/stretchr/testify/assert"
"testing"
)

View file

@ -3,8 +3,8 @@ package acltree
import (
"errors"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread"
"github.com/anytypeio/go-anytype-infrastructure-experiments/thread"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
//"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/lib/logging"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"

View file

@ -2,12 +2,12 @@ package plaintextdocument
import (
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/account"
aclpb "github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges/pb"
acltree2 "github.com/anytypeio/go-anytype-infrastructure-experiments/acl/acltree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/testutils/testchanges/pb"
thread2 "github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread"
"github.com/anytypeio/go-anytype-infrastructure-experiments/account"
aclpb "github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acltree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/testutils/testchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/thread"
"github.com/gogo/protobuf/proto"
)
@ -18,7 +18,7 @@ type PlainTextDocument interface {
type plainTextDocument struct {
heads []string
aclTree acltree.ACLTree
aclTree acltree2.ACLTree
state *DocumentState
}
@ -30,7 +30,7 @@ func (p *plainTextDocument) Text() string {
}
func (p *plainTextDocument) AddText(text string) error {
_, err := p.aclTree.AddContent(func(builder acltree.ChangeBuilder) error {
_, err := p.aclTree.AddContent(func(builder acltree2.ChangeBuilder) error {
builder.AddChangeContent(
&pb.PlainTextChangeData{
Content: []*pb.PlainTextChangeContent{
@ -42,7 +42,7 @@ func (p *plainTextDocument) AddText(text string) error {
return err
}
func (p *plainTextDocument) Update(tree acltree.ACLTree) {
func (p *plainTextDocument) Update(tree acltree2.ACLTree) {
p.aclTree = tree
var err error
defer func() {
@ -54,7 +54,7 @@ func (p *plainTextDocument) Update(tree acltree.ACLTree) {
prevHeads := p.heads
p.heads = tree.Heads()
startId := prevHeads[0]
tree.IterateFrom(startId, func(change *acltree.Change) (isContinue bool) {
tree.IterateFrom(startId, func(change *acltree2.Change) (isContinue bool) {
if change.Id == startId {
return true
}
@ -68,7 +68,7 @@ func (p *plainTextDocument) Update(tree acltree.ACLTree) {
})
}
func (p *plainTextDocument) Rebuild(tree acltree.ACLTree) {
func (p *plainTextDocument) Rebuild(tree acltree2.ACLTree) {
p.aclTree = tree
p.heads = tree.Heads()
var startId string
@ -92,7 +92,7 @@ func (p *plainTextDocument) Rebuild(tree acltree.ACLTree) {
}
startId = rootChange.Id
tree.Iterate(func(change *acltree.Change) (isContinue bool) {
tree.Iterate(func(change *acltree2.Change) (isContinue bool) {
if startId == change.Id {
return true
}
@ -111,14 +111,14 @@ func (p *plainTextDocument) Rebuild(tree acltree.ACLTree) {
}
func NewInMemoryPlainTextDocument(acc *account.AccountData, text string) (PlainTextDocument, error) {
return NewPlainTextDocument(acc, thread.NewInMemoryThread, text)
return NewPlainTextDocument(acc, thread2.NewInMemoryThread, text)
}
func NewPlainTextDocument(
acc *account.AccountData,
create func(change *thread.RawChange) (thread.Thread, error),
create func(change *thread2.RawChange) (thread2.Thread, error),
text string) (PlainTextDocument, error) {
changeBuilder := func(builder acltree.ChangeBuilder) error {
changeBuilder := func(builder acltree2.ChangeBuilder) error {
err := builder.UserAdd(acc.Identity, acc.EncKey.GetPublic(), aclpb.ACLChange_Admin)
if err != nil {
return err
@ -126,7 +126,7 @@ func NewPlainTextDocument(
builder.AddChangeContent(createInitialChangeContent(text))
return nil
}
t, err := acltree.BuildThreadWithACL(
t, err := acltree2.BuildThreadWithACL(
acc,
changeBuilder,
create)
@ -139,7 +139,7 @@ func NewPlainTextDocument(
aclTree: nil,
state: nil,
}
tree, err := acltree.BuildACLTree(t, acc, doc)
tree, err := acltree2.BuildACLTree(t, acc, doc)
if err != nil {
return nil, err
}

View file

@ -1,9 +1,9 @@
package plaintextdocument
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/testutils/threadbuilder"
"github.com/anytypeio/go-anytype-infrastructure-experiments/thread"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/testutils/threadbuilder"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread"
"github.com/stretchr/testify/assert"
"testing"
)

View file

@ -2,8 +2,8 @@ package plaintextdocument
import (
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/testutils/testchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/testutils/testchanges/pb"
"github.com/gogo/protobuf/proto"
)

View file

@ -3,8 +3,12 @@ package threadbuilder
import (
"context"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges"
"github.com/anytypeio/go-anytype-infrastructure-experiments/testutils/yamltests"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges/pb"
testpb "github.com/anytypeio/go-anytype-infrastructure-experiments/acl/testutils/testchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/testutils/yamltests"
thread2 "github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread"
threadpb "github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
"io/ioutil"
"path"
@ -12,10 +16,6 @@ import (
"github.com/gogo/protobuf/proto"
"gopkg.in/yaml.v3"
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges/pb"
testpb "github.com/anytypeio/go-anytype-infrastructure-experiments/testutils/testchanges/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/thread"
threadpb "github.com/anytypeio/go-anytype-infrastructure-experiments/thread/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
)
@ -87,7 +87,7 @@ func (t *ThreadBuilder) Heads() []string {
return t.heads
}
func (t *ThreadBuilder) AddRawChange(change *thread.RawChange) error {
func (t *ThreadBuilder) AddRawChange(change *thread2.RawChange) error {
aclChange := new(pb.ACLChange)
var err error
@ -162,12 +162,12 @@ func (t *ThreadBuilder) RemoveOrphans(orphans ...string) {
t.orphans = slice.Difference(t.orphans, orphans)
}
func (t *ThreadBuilder) GetChange(ctx context.Context, recordID string) (*thread.RawChange, error) {
func (t *ThreadBuilder) GetChange(ctx context.Context, recordID string) (*thread2.RawChange, error) {
return t.getChange(recordID, t.allChanges), nil
}
func (t *ThreadBuilder) GetUpdates(useCase string) []*thread.RawChange {
var res []*thread.RawChange
func (t *ThreadBuilder) GetUpdates(useCase string) []*thread2.RawChange {
var res []*thread2.RawChange
update := t.updates[useCase]
for _, ch := range update.changes {
rawCh := t.getChange(ch.id, update.changes)
@ -180,7 +180,7 @@ func (t *ThreadBuilder) Header() *threadpb.ThreadHeader {
return t.header
}
func (t *ThreadBuilder) getChange(changeId string, m map[string]*threadChange) *thread.RawChange {
func (t *ThreadBuilder) getChange(changeId string, m map[string]*threadChange) *thread2.RawChange {
rec := m[changeId]
if rec.changesDataDecrypted != nil {
@ -202,7 +202,7 @@ func (t *ThreadBuilder) getChange(changeId string, m map[string]*threadChange) *
panic("should be able to sign final acl message!")
}
transformedRec := &thread.RawChange{
transformedRec := &thread2.RawChange{
Payload: aclMarshaled,
Signature: signature,
Id: changeId,
@ -279,7 +279,7 @@ func (t *ThreadBuilder) parseThreadId(description *ThreadDescription) string {
panic("no author in thread")
}
key := t.keychain.SigningKeys[description.Author]
id, err := thread.CreateACLThreadID(key.GetPublic(), plainTextDocType)
id, err := thread2.CreateACLThreadID(key.GetPublic(), plainTextDocType)
if err != nil {
panic(err)
}

View file

@ -9,14 +9,13 @@ package threadbuilder
import (
"fmt"
testpb "github.com/anytypeio/go-anytype-infrastructure-experiments/acl/testutils/testchanges/pb"
"github.com/gogo/protobuf/proto"
"strings"
"unicode"
"github.com/awalterschulze/gographviz"
testpb "github.com/anytypeio/go-anytype-infrastructure-experiments/testutils/testchanges/pb"
)
// To quickly look at visualized string you can use https://dreampuf.github.io/GraphvizOnline

View file

@ -3,8 +3,8 @@ package thread
import (
"context"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges"
"github.com/anytypeio/go-anytype-infrastructure-experiments/thread/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
"github.com/gogo/protobuf/proto"

View file

@ -2,9 +2,8 @@ package thread
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/thread/pb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/aclchanges"
"github.com/anytypeio/go-anytype-infrastructure-experiments/acl/thread/pb"
)
// TODO: change methods to have errors as a return parameter, because we will be dealing with a real database