thread

package
v0.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RepoPath      string
	Ipfs          func() *core.IpfsNode
	Blocks        func() repo.BlockStore
	Peers         func() repo.PeerStore
	Notifications func() repo.NotificationStore
	GetHead       func() (string, error)
	UpdateHead    func(head string) error
	Publish       func(payload []byte) error
	Send          func(message *pb.Envelope, peerId string, hash *string) error
	NewEnvelope   func(message *pb.Message) (*pb.Envelope, error)
	PutPinRequest func(id string) error
	GetUsername   func() (*string, error)
	SendUpdate    func(update Update)
}

Config is used to construct a Thread

type Info

type Info struct {
	Head        *repo.Block `json:"head,omitempty"`
	BlockCount  int         `json:"block_count"`
	LatestPhoto *repo.Block `json:"latest_photo,omitempty"`
	PhotoCount  int         `json:"photo_count"`
}

Info reports info about a thread

type Thread

type Thread struct {
	Id      string
	Name    string
	PrivKey libp2pc.PrivKey

	GetHead func() (string, error)
	// contains filtered or unexported fields
}

Thread is the primary mechanism representing a collecion of data / files / photos

func NewThread

func NewThread(model *repo.Thread, config *Config) (*Thread, error)

NewThread create a new Thread from a repo model and config

func (*Thread) AddComment

func (t *Thread) AddComment(dataId string, body string) (mh.Multihash, error)

AddComment adds an outgoing comment block

func (*Thread) AddExternalInvite

func (t *Thread) AddExternalInvite() (mh.Multihash, []byte, error)

AddExternalInvite creates an external invite, which can be retrieved by any peer and does not become part of the hash chain

func (*Thread) AddInvite

func (t *Thread) AddInvite(inviteePk libp2pc.PubKey) (mh.Multihash, error)

AddInvite creates an outgoing invite block, which is sent directly to the recipient and does not become part of the hash chain

func (*Thread) AddLike

func (t *Thread) AddLike(dataId string) (mh.Multihash, error)

AddLike adds an outgoing like block

func (*Thread) AddPhoto

func (t *Thread) AddPhoto(dataId string, caption string, key []byte) (mh.Multihash, error)

AddPhoto adds an outgoing photo block

func (*Thread) Blocks

func (t *Thread) Blocks(offsetId string, limit int, btype *repo.BlockType, dataId *string) []repo.Block

Blocks paginates blocks from the datastore

func (*Thread) Decrypt

func (t *Thread) Decrypt(data []byte) ([]byte, error)

Decrypt data with thread secret key

func (*Thread) Encrypt

func (t *Thread) Encrypt(data []byte) ([]byte, error)

Encrypt data with thread public key

func (*Thread) FollowParents

func (t *Thread) FollowParents(parents []string, from *peer.ID) ([]repo.Peer, error)

FollowParents tries to follow a list of chains of block ids, processing along the way

func (*Thread) GetBlockData

func (t *Thread) GetBlockData(path string, block *repo.Block) ([]byte, error)

GetBlockData cats file data from ipfs and tries to decrypt it with the provided block

func (*Thread) GetBlockDataKey

func (t *Thread) GetBlockDataKey(block *repo.Block) ([]byte, error)

GetBlockDataKey returns the decrypted AES key for a block

func (*Thread) GetPhotoMetaData

func (t *Thread) GetPhotoMetaData(id string, block *repo.Block) (*util.PhotoMetadata, error)

GetPhotoMetaData returns photo metadata indexed under a block

func (*Thread) HandleAnnotationBlock

func (t *Thread) HandleAnnotationBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, content *pb.ThreadAnnotation, following bool) (mh.Multihash, error)

HandleAnnotationBlock handles an incoming data block

func (*Thread) HandleDataBlock

func (t *Thread) HandleDataBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, content *pb.ThreadData, following bool) (mh.Multihash, error)

HandleDataBlock handles an incoming data block

func (*Thread) HandleExternalInviteMessage

func (t *Thread) HandleExternalInviteMessage(content *pb.ThreadExternalInvite) error

HandleExternalInviteMessage handles an incoming external invite - this happens right before a join - the invite is not kept on-chain, so we only need to follow parents and update HEAD

func (*Thread) HandleIgnoreBlock

func (t *Thread) HandleIgnoreBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, content *pb.ThreadIgnore, following bool) (mh.Multihash, error)

HandleIgnoreBlock handles an incoming ignore block

func (*Thread) HandleInviteMessage

func (t *Thread) HandleInviteMessage(content *pb.ThreadInvite) error

HandleInviteMessage handles an incoming invite - this happens right before a join - the invite is not kept on-chain, so we only need to follow parents and update HEAD

func (*Thread) HandleJoinBlock

func (t *Thread) HandleJoinBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, content *pb.ThreadJoin, following bool) (mh.Multihash, *repo.Peer, error)

HandleJoinBlock handles an incoming join block

func (*Thread) HandleLeaveBlock

func (t *Thread) HandleLeaveBlock(from *peer.ID, env *pb.Envelope, signed *pb.SignedThreadBlock, content *pb.ThreadLeave, following bool) (mh.Multihash, error)

HandleLeaveBlock handles an incoming leave block

func (*Thread) HandleMergeBlock

func (t *Thread) HandleMergeBlock(from *peer.ID, message *pb.Message, signed *pb.SignedThreadBlock, content *pb.ThreadMerge, following bool) (mh.Multihash, error)

HandleMergeBlock handles an incoming merge block

func (*Thread) Ignore

func (t *Thread) Ignore(blockId string) (mh.Multihash, error)

Ignore adds an outgoing ignore block targeted at another block to ignore

func (*Thread) Info

func (t *Thread) Info() (*Info, error)

Info returns thread info

func (*Thread) Join

func (t *Thread) Join(inviterPk libp2pc.PubKey, blockId string) (mh.Multihash, error)

Join creates an outgoing join block

func (*Thread) JoinInitial

func (t *Thread) JoinInitial() (mh.Multihash, error)

JoinInitial creates an outgoing join block for an emtpy thread

func (*Thread) Leave

func (t *Thread) Leave() (mh.Multihash, error)

Leave creates an outgoing leave block

func (*Thread) Merge

func (t *Thread) Merge(head string) (mh.Multihash, error)

Merge adds a merge block, which are kept local until subsequent updates, avoiding possibly endless echoes

func (*Thread) Peers

func (t *Thread) Peers() []repo.Peer

Peers returns locally known peers in this thread

func (*Thread) Verify

func (t *Thread) Verify(signed *pb.SignedThreadBlock) error

Verify verifies a signed block

type Update

type Update struct {
	Block      repo.Block `json:"block"`
	ThreadId   string     `json:"thread_id"`
	ThreadName string     `json:"thread_name"`
}

Update is used to notify listeners about updates in a thread

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL