diff --git a/README.md b/README.md index 2d2633c5..dce26307 100644 --- a/README.md +++ b/README.md @@ -75,11 +75,11 @@ Check out the [docs site](https://docs.textile.io/) for more detailed usage inst ## Building -There are various things to build… first off run setup: +There are various things to build… first off, run setup: make setup -If you plan on building the bindings fro iOS or Android, install and init the `gomobile` tools: +If you plan on building the bindings for iOS or Android, install and init the `gomobile` tools: go get golang.org/x/mobile/cmd/gomobile gomobile init @@ -100,11 +100,11 @@ If you plan on building the bindings fro iOS or Android, install and init the `g make docs -#### Tray app +#### Desktop -The build is made by a vendored version of `go-astilectron-bundler`. Due to Go's painful package management, you'll want to delete any `go-astilectron`-related binaries and source code you have installed from `github.com/asticode` in your `$GOPATH`. Then you can install the vendored `go-astilectron-bundler`: +Install `go-astilectron-bundler`: - go install ./vendor/github.com/asticode/go-astilectron-bundler/astilectron-bundler + go get github.com/asticode/go-astilectron-bundler/... Change into the `tray` folder and build the app: @@ -113,7 +113,6 @@ Change into the `tray` folder and build the app: Double-click the built app in `tray/output/{darwin,linux,windows}-amd64`, or run it directly: - go run *.go You can also build the architecture-specific versions with: diff --git a/core/api_blocks.go b/core/api_blocks.go index 608d0007..d4b9031e 100644 --- a/core/api_blocks.go +++ b/core/api_blocks.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" "strconv" + "strings" "github.com/gin-gonic/gin" "github.com/textileio/go-textile/ipfs" @@ -177,12 +178,15 @@ func (a *api) toDots(blocks *pb.BlockList) (string, error) { dot := toDot(b) for _, p := range b.Parents { + if strings.TrimSpace(p) == "" { + continue + } pp, err := a.node.Block(p) if err != nil { - log.Errorf("error getting block %s: %s", p, err) + log.Warningf("block %s: %s", p, err) + dots += "\n " + dot + " -> MISSING_" + pre(p) + ";" continue } - dots += "\n " + dot + " -> " + toDot(pp) + ";" } } diff --git a/core/invites.go b/core/invites.go index 9edcf5da..640ca200 100644 --- a/core/invites.go +++ b/core/invites.go @@ -99,8 +99,8 @@ func (t *Textile) Invites() *pb.InviteViewList { } // AcceptInvite adds a new thread, and notifies the inviter of the join -func (t *Textile) AcceptInvite(inviteId string) (mh.Multihash, error) { - invite := t.datastore.Invites().Get(inviteId) +func (t *Textile) AcceptInvite(id string) (mh.Multihash, error) { + invite := t.datastore.Invites().Get(id) if invite == nil { return nil, ErrThreadInviteNotFound } @@ -110,7 +110,7 @@ func (t *Textile) AcceptInvite(inviteId string) (mh.Multihash, error) { return nil, err } - if err := t.IgnoreInvite(inviteId); err != nil { + if err := t.IgnoreInvite(id); err != nil { return nil, err } @@ -119,8 +119,8 @@ func (t *Textile) AcceptInvite(inviteId string) (mh.Multihash, error) { // AcceptExternalInvite attemps to download an encrypted thread key from an external invite, // adds a new thread, and notifies the inviter of the join -func (t *Textile) AcceptExternalInvite(inviteId string, key []byte) (mh.Multihash, error) { - ciphertext, err := ipfs.DataAtPath(t.node, fmt.Sprintf("%s", inviteId)) +func (t *Textile) AcceptExternalInvite(id string, key []byte) (mh.Multihash, error) { + ciphertext, err := ipfs.DataAtPath(t.node, fmt.Sprintf("%s", id)) if err != nil { return nil, err } @@ -134,11 +134,11 @@ func (t *Textile) AcceptExternalInvite(inviteId string, key []byte) (mh.Multihas } // IgnoreInvite deletes the invite and removes the associated notification. -func (t *Textile) IgnoreInvite(inviteId string) error { - if err := t.datastore.Invites().Delete(inviteId); err != nil { +func (t *Textile) IgnoreInvite(id string) error { + if err := t.datastore.Invites().Delete(id); err != nil { return err } - return t.datastore.Notifications().DeleteByBlock(inviteId) + return t.datastore.Notifications().DeleteByBlock(id) } // handleThreadAdd uses an add block to join a thread diff --git a/mobile/invites.go b/mobile/invites.go index 56e0aa5d..39075921 100644 --- a/mobile/invites.go +++ b/mobile/invites.go @@ -29,7 +29,26 @@ func (m *Mobile) AddExternalInvite(threadId string) ([]byte, error) { return proto.Marshal(invite) } -// AcceptExternalInvite notifies the thread of a join +// Invites calls core Invites +func (m *Mobile) Invites() ([]byte, error) { + return proto.Marshal(m.node.Invites()) +} + +// AcceptInvite calls core AcceptInvite +func (m *Mobile) AcceptInvite(id string) (string, error) { + if !m.node.Online() { + return "", core.ErrOffline + } + + hash, err := m.node.AcceptInvite(id) + if err != nil { + return "", err + } + + return hash.B58String(), nil +} + +// AcceptExternalInvite calls core AcceptExternalInvite func (m *Mobile) AcceptExternalInvite(id string, key string) (string, error) { if !m.node.Online() { return "", core.ErrOffline @@ -47,3 +66,12 @@ func (m *Mobile) AcceptExternalInvite(id string, key string) (string, error) { return hash.B58String(), nil } + +// IgnoreInvite calls core IgnoreInvite +func (m *Mobile) IgnoreInvite(id string) error { + if !m.node.Online() { + return core.ErrOffline + } + + return m.node.IgnoreInvite(id) +}