-
Notifications
You must be signed in to change notification settings - Fork 43
/
textile.go
79 lines (69 loc) · 3.13 KB
/
textile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package textile
import (
"context"
"io"
"github.com/ipfs/go-cid"
"github.com/FleekHQ/space-daemon/config"
"github.com/FleekHQ/space-daemon/core/space/domain"
"github.com/FleekHQ/space-daemon/core/textile/bucket"
"github.com/FleekHQ/space-daemon/core/textile/model"
"github.com/FleekHQ/space-daemon/core/textile/sync"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/textileio/go-threads/db"
buckets_pb "github.com/textileio/textile/v2/api/buckets/pb"
"github.com/textileio/textile/v2/api/users/client"
threadsClient "github.com/textileio/go-threads/api/client"
)
const (
hubTarget = "127.0.0.1:3006"
threadsTarget = "127.0.0.1:3006"
defaultPersonalBucketSlug = "personal"
defaultCacheBucketSlug = "personal_cache"
defaultPersonalMirrorBucketSlug = "personal_mirror"
defaultPublicShareBucketSlug = "personal_public"
)
type BucketRoot buckets_pb.Root
type Bucket interface {
bucket.BucketInterface
}
type Client interface {
IsRunning() bool
IsInitialized() bool
IsHealthy() bool
GetDefaultBucket(ctx context.Context) (Bucket, error)
GetBucket(ctx context.Context, slug string, remoteFile *GetBucketForRemoteFileInput) (Bucket, error)
GetThreadsConnection() (*threadsClient.Client, error)
GetModel() model.Model
ListBuckets(ctx context.Context) ([]Bucket, error)
ShareBucket(ctx context.Context, bucketSlug string) (*db.Info, error)
JoinBucket(ctx context.Context, slug string, ti *domain.ThreadInfo) (bool, error)
CreateBucket(ctx context.Context, bucketSlug string) (Bucket, error)
ToggleBucketBackup(ctx context.Context, bucketSlug string, bucketBackup bool) (bool, error)
SendMessage(ctx context.Context, recipient crypto.PubKey, body []byte) (*client.Message, error)
Shutdown() error
WaitForReady() chan bool
WaitForHealthy() chan error
WaitForInitialized() chan bool
Start(ctx context.Context, cfg config.Config) error
GetMailAsNotifications(ctx context.Context, seek string, limit int) ([]*domain.Notification, error)
ShareFilesViaPublicKey(ctx context.Context, paths []domain.FullPath, pubkeys []crypto.PubKey, keys [][]byte) error
AcceptSharedFilesInvitation(ctx context.Context, invitation domain.Invitation) (domain.Invitation, error)
RejectSharedFilesInvitation(ctx context.Context, invitation domain.Invitation) (domain.Invitation, error)
AcceptSharedFileLink(
ctx context.Context,
cidHash, password, filename, fileSize string,
) (*domain.SharedDirEntry, error)
RemoveKeys(ctx context.Context) error
AttachMailboxNotifier(notif GrpcMailboxNotifier)
AttachSynchronizerNotifier(notif sync.EventNotifier)
GetReceivedFiles(ctx context.Context, accepted bool, seek string, limit int) ([]*domain.SharedDirEntry, string, error)
GetPublicReceivedFile(ctx context.Context, cidHash string, accepted bool) (*domain.SharedDirEntry, string, error)
GetPathAccessRoles(ctx context.Context, b Bucket, path string) ([]domain.Member, error)
GetPublicShareBucket(ctx context.Context) (Bucket, error)
DownloadPublicGatewayItem(ctx context.Context, cid cid.Cid) (io.ReadCloser, error)
GetFailedHealthchecks() int
}
type Buckd interface {
Stop() error
Start(ctx context.Context) error
}