repo

package
v1.0.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMigrationRequired = errors.New("repo needs migration")
View Source
var ErrRepoCorrupted = errors.New("repo is corrupted")
View Source
var ErrRepoDoesNotExist = errors.New("repo does not exist, initialization is required")
View Source
var ErrRepoExists = errors.New("repo not empty, reinitializing would overwrite your account")

Functions

func ConflictError

func ConflictError(err error) bool

func Init

func Init(repoPath string, version string) error

func MigrateUp

func MigrateUp(repoPath string, pinCode string, testnet bool) error

MigrateUp applies minor migrations all the way up to current

func Stat

func Stat(repoPath string) error

Stat returns whether or not there's a major migration ahead of the current repover

Types

type Block

type Block struct {
	Id       string    `json:"id"`
	ThreadId string    `json:"thread_id"`
	AuthorId string    `json:"author_id"`
	Type     BlockType `json:"type"`
	Date     time.Time `json:"date"`
	Parents  []string  `json:"parents"`
	Target   string    `json:"target,omitempty"`
	Body     string    `json:"body,omitempty"`
}

type BlockStore

type BlockStore interface {
	Queryable
	Add(block *Block) error
	Get(id string) *Block
	List(offset string, limit int, query string) []Block
	Count(query string) int
	Delete(id string) error
	DeleteByThread(threadId string) error
}

type BlockType

type BlockType int
const (
	MergeBlock BlockType = iota
	IgnoreBlock
	FlagBlock
	JoinBlock
	AnnounceBlock
	LeaveBlock
	MessageBlock
	FilesBlock
	CommentBlock
	LikeBlock
)

func (BlockType) Description

func (b BlockType) Description() string

type CafeClient

type CafeClient struct {
	Id       string    `json:"id"`
	Address  string    `json:"address"`
	Created  time.Time `json:"created"`
	LastSeen time.Time `json:"last_seen"`
}

type CafeClientMessage

type CafeClientMessage struct {
	Id       string    `json:"id"`
	PeerId   string    `json:"peer_id"`
	ClientId string    `json:"client_id"`
	Date     time.Time `json:"date"`
}

type CafeClientMessageStore

type CafeClientMessageStore interface {
	AddOrUpdate(message *CafeClientMessage) error
	ListByClient(clientId string, limit int) []CafeClientMessage
	CountByClient(clientId string) int
	Delete(id string, clientId string) error
	DeleteByClient(clientId string, limit int) error
}

type CafeClientNonce

type CafeClientNonce struct {
	Value   string    `json:"value"`
	Address string    `json:"address"`
	Date    time.Time `json:"date"`
}

type CafeClientNonceStore

type CafeClientNonceStore interface {
	Add(nonce *CafeClientNonce) error
	Get(value string) *CafeClientNonce
	Delete(value string) error
}

type CafeClientStore

type CafeClientStore interface {
	Add(account *CafeClient) error
	Get(id string) *CafeClient
	Count() int
	List() []CafeClient
	ListByAddress(address string) []CafeClient
	UpdateLastSeen(id string, date time.Time) error
	Delete(id string) error
}

type CafeClientThread

type CafeClientThread struct {
	Id         string `json:"id"`
	ClientId   string `json:"client_id"`
	Ciphertext []byte `json:"ciphertext"`
}

type CafeClientThreadStore

type CafeClientThreadStore interface {
	AddOrUpdate(thrd *CafeClientThread) error
	ListByClient(clientId string) []CafeClientThread
	Delete(id string, clientId string) error
	DeleteByClient(clientId string) error
}

type CafeMessage

type CafeMessage struct {
	Id     string    `json:"id"`
	PeerId string    `json:"peer_id"`
	Date   time.Time `json:"date"`
}

type CafeMessageStore

type CafeMessageStore interface {
	Queryable
	Add(msg *CafeMessage) error
	List(offset string, limit int) []CafeMessage
	Delete(id string) error
}

type CafeRequest

type CafeRequest struct {
	Id       string          `json:"id"`
	PeerId   string          `json:"peer_id"`
	TargetId string          `json:"target_id"`
	CafeId   string          `json:"cafe_id"`
	Type     CafeRequestType `json:"type"`
	Date     time.Time       `json:"date"`
}

type CafeRequestStore

type CafeRequestStore interface {
	Queryable
	Add(req *CafeRequest) error
	List(offset string, limit int) []CafeRequest
	Delete(id string) error
	DeleteByCafe(cafeId string) error
}

type CafeRequestType

type CafeRequestType int
const (
	CafeStoreRequest CafeRequestType = iota
	CafeStoreThreadRequest
	CafePeerInboxRequest
)

func (CafeRequestType) Description

func (rt CafeRequestType) Description() string

type CafeSession

type CafeSession struct {
	CafeId     string    `json:"cafe_id"`
	Access     string    `json:"access"`
	Refresh    string    `json:"refresh"`
	Expiry     time.Time `json:"expiry"`
	HttpAddr   string    `json:"http_addr"`
	SwarmAddrs []string  `json:"swarm_addrs"`
}

type CafeSessionStore

type CafeSessionStore interface {
	AddOrUpdate(session *CafeSession) error
	Get(cafeId string) *CafeSession
	List() []CafeSession
	Delete(cafeId string) error
}

type ConfigStore

type ConfigStore interface {
	Init(pin string) error
	Configure(accnt *keypair.Full, created time.Time) error
	GetAccount() (*keypair.Full, error)
	GetCreationDate() (time.Time, error)
	IsEncrypted() bool
}

type Contact

type Contact struct {
	Id       string    `json:"id"`
	Address  string    `json:"address"`
	Username string    `json:"username"`
	Inboxes  []string  `json:"inboxes"`
	Added    time.Time `json:"added"`
}

type ContactStore

type ContactStore interface {
	Queryable
	Add(device *Contact) error
	AddOrUpdate(device *Contact) error
	Get(id string) *Contact
	List() []Contact
	ListByAddress(address string) []Contact
	Count() int
	Delete(id string) error
}

type Datastore

type Datastore interface {
	Config() ConfigStore
	Profile() ProfileStore
	Contacts() ContactStore
	Files() FileStore
	Threads() ThreadStore
	ThreadInvites() ThreadInviteStore
	ThreadPeers() ThreadPeerStore
	ThreadMessages() ThreadMessageStore
	Blocks() BlockStore
	Notifications() NotificationStore
	CafeSessions() CafeSessionStore
	CafeRequests() CafeRequestStore
	CafeMessages() CafeMessageStore
	CafeClientNonces() CafeClientNonceStore
	CafeClients() CafeClientStore
	CafeClientThreads() CafeClientThreadStore
	CafeClientMessages() CafeClientMessageStore
	Ping() error
	Close()
}

type File

type File struct {
	Mill     string                 `json:"mill"`
	Checksum string                 `json:"checksum"`
	Source   string                 `json:"source"`
	Opts     string                 `json:"opts,omitempty"`
	Hash     string                 `json:"hash"`
	Key      string                 `json:"key,omitempty"`
	Media    string                 `json:"media"`
	Name     string                 `json:"name,omitempty"`
	Size     int                    `json:"size"`
	Added    time.Time              `json:"added"`
	Meta     map[string]interface{} `json:"meta,omitempty"`
	Targets  []string               `json:"targets,omitempty"`
}

type FileStore

type FileStore interface {
	Queryable
	Add(file *File) error
	Get(hash string) *File
	GetByPrimary(mill string, checksum string) *File
	GetBySource(mill string, source string, opts string) *File
	AddTarget(hash string, target string) error
	RemoveTarget(hash string, target string) error
	Count() int
	Delete(hash string) error
}

type Migration

type Migration interface {
	Up(repoPath string, pinCode string, testnet bool) error
	Down(repoPath string, pinCode string, testnet bool) error
	Major() bool
}

Migration performs minor up and down migrations

type Notification

type Notification struct {
	Id        string           `json:"id"`
	Date      time.Time        `json:"date"`
	ActorId   string           `json:"actor_id"`
	Subject   string           `json:"subject"`
	SubjectId string           `json:"subject_id"`
	BlockId   string           `json:"block_id,omitempty"`
	Target    string           `json:"target,omitempty"`
	Type      NotificationType `json:"type"`
	Body      string           `json:"body"`
	Read      bool             `json:"read"`
}

type NotificationStore

type NotificationStore interface {
	Queryable
	Add(notification *Notification) error
	Get(id string) *Notification
	Read(id string) error
	ReadAll() error
	List(offset string, limit int) []Notification
	CountUnread() int
	Delete(id string) error
	DeleteByActor(actorId string) error
	DeleteBySubject(subjectId string) error
	DeleteByBlock(blockId string) error
}

type NotificationType

type NotificationType int
const (
	InviteReceivedNotification NotificationType = iota
	AccountPeerJoinedNotification
	PeerJoinedNotification
	PeerLeftNotification
	MessageAddedNotification
	FilesAddedNotification
	CommentAddedNotification
	LikeAddedNotification
)

func (NotificationType) Description

func (n NotificationType) Description() string

type ProfileStore

type ProfileStore interface {
	SetUsername(username string) error
	GetUsername() (*string, error)
	SetAvatar(uri string) error
	GetAvatar() (*string, error)
}

type Queryable

type Queryable interface {
	BeginTransaction() (*sql.Tx, error)
	PrepareQuery(string) (*sql.Stmt, error)
	PrepareAndExecuteQuery(string, ...interface{}) (*sql.Rows, error)
	ExecuteQuery(string, ...interface{}) (sql.Result, error)
}

type Thread

type Thread struct {
	Id        string      `json:"id"`
	Key       string      `json:"key"`
	PrivKey   []byte      `json:"sk"`
	Name      string      `json:"name"`
	Schema    string      `json:"schema"`
	Initiator string      `json:"initiator"`
	Type      ThreadType  `json:"type"`
	State     ThreadState `json:"state"`
	Head      string      `json:"head"`
}

type ThreadInvite

type ThreadInvite struct {
	Id      string    `json:"id"`
	Block   []byte    `json:"block"`
	Name    string    `json:"name"`
	Inviter string    `json:"inviter"`
	Date    time.Time `json:"date"`
}

type ThreadInviteStore

type ThreadInviteStore interface {
	Queryable
	Add(invite *ThreadInvite) error
	Get(id string) *ThreadInvite
	List() []ThreadInvite
	Delete(id string) error
}

type ThreadMessage

type ThreadMessage struct {
	Id       string       `json:"id"`
	PeerId   string       `json:"peer_id"`
	Envelope *pb.Envelope `json:"envelope"`
	Date     time.Time    `json:"date"`
}

type ThreadMessageStore

type ThreadMessageStore interface {
	Queryable
	Add(msg *ThreadMessage) error
	List(offset string, limit int) []ThreadMessage
	Delete(id string) error
}

type ThreadPeer

type ThreadPeer struct {
	Id       string `json:"id"`
	ThreadId string `json:"thread_id"`
	Welcomed bool   `json:"welcomed"`
}

type ThreadPeerStore

type ThreadPeerStore interface {
	Queryable
	Add(peer *ThreadPeer) error
	List() []ThreadPeer
	ListById(id string) []ThreadPeer
	ListByThread(threadId string) []ThreadPeer
	ListUnwelcomedByThread(threadId string) []ThreadPeer
	WelcomeByThread(thread string) error
	Count(distinct bool) int
	Delete(id string, thread string) error
	DeleteById(id string) error
	DeleteByThread(thread string) error
}

type ThreadState

type ThreadState int
const (
	ThreadLoading ThreadState = iota
	ThreadLoaded
)

func (ThreadState) Description

func (ts ThreadState) Description() string

type ThreadStore

type ThreadStore interface {
	Queryable
	Add(thread *Thread) error
	Get(id string) *Thread
	GetByKey(key string) *Thread
	List() []Thread
	Count() int
	UpdateHead(id string, head string) error
	Delete(id string) error
}

type ThreadType

type ThreadType int
const (
	PrivateThread  ThreadType = iota // invites not allowed
	ReadOnlyThread                   // all non-initiator writes ignored
	PublicThread                     // only non-initiator file writes ignored (annotations allowed)
	OpenThread                       // all writes allowed
)

in order of decreasing privacy

func ThreadTypeFromString

func ThreadTypeFromString(desc string) (ThreadType, error)

func (ThreadType) Description

func (tt ThreadType) Description() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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