collections

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidThreadName = fmt.Errorf("name may only contain alphanumeric characters or non-consecutive hyphens, and cannot begin or end with a hyphen")
)
View Source
var (
	ErrInvalidUsername = fmt.Errorf("username may only contain alphanumeric characters or single hyphens, and cannot begin or end with a hyphen")
)

Functions

func NewAPIKeyContext added in v1.0.0

func NewAPIKeyContext(ctx context.Context, key *APIKey) context.Context

func NewDevContext added in v1.0.0

func NewDevContext(ctx context.Context, dev *Account) context.Context

func NewOrgContext added in v1.0.0

func NewOrgContext(ctx context.Context, org *Account) context.Context

func NewSessionContext added in v1.0.0

func NewSessionContext(ctx context.Context, session *Session) context.Context

func NewUserContext added in v1.0.0

func NewUserContext(ctx context.Context, user *User) context.Context

Types

type APIKey added in v1.0.0

type APIKey struct {
	Key       string
	Secret    string
	Owner     crypto.PubKey
	Type      APIKeyType
	Valid     bool
	CreatedAt time.Time
}

func APIKeyFromContext added in v1.0.0

func APIKeyFromContext(ctx context.Context) (*APIKey, bool)

type APIKeyType added in v1.0.0

type APIKeyType int
const (
	AccountKey APIKeyType = iota
	UserKey
)

type APIKeys added in v1.0.0

type APIKeys struct {
	// contains filtered or unexported fields
}

func NewAPIKeys added in v1.0.0

func NewAPIKeys(ctx context.Context, db *mongo.Database) (*APIKeys, error)

func (*APIKeys) Create added in v1.0.0

func (k *APIKeys) Create(ctx context.Context, owner crypto.PubKey, keyType APIKeyType) (*APIKey, error)

func (*APIKeys) DeleteByOwner added in v1.0.2

func (k *APIKeys) DeleteByOwner(ctx context.Context, owner crypto.PubKey) error

func (*APIKeys) Get added in v1.0.0

func (k *APIKeys) Get(ctx context.Context, key string) (*APIKey, error)

func (*APIKeys) Invalidate added in v1.0.0

func (k *APIKeys) Invalidate(ctx context.Context, key string) error

func (*APIKeys) ListByOwner added in v1.0.2

func (k *APIKeys) ListByOwner(ctx context.Context, owner crypto.PubKey) ([]APIKey, error)

type Account added in v1.0.0

type Account struct {
	Type      AccountType
	Key       crypto.PubKey
	Secret    crypto.PrivKey
	Name      string
	Username  string
	Email     string
	Token     thread.Token
	Members   []Member
	CreatedAt time.Time
}

func DevFromContext added in v1.0.0

func DevFromContext(ctx context.Context) (*Account, bool)

func OrgFromContext added in v1.0.0

func OrgFromContext(ctx context.Context) (*Account, bool)

type AccountType added in v1.0.0

type AccountType int
const (
	Dev AccountType = iota
	Org
)

type Accounts added in v1.0.0

type Accounts struct {
	// contains filtered or unexported fields
}

func NewAccounts added in v1.0.0

func NewAccounts(ctx context.Context, db *mongo.Database) (*Accounts, error)

func (*Accounts) AddMember added in v1.0.0

func (a *Accounts) AddMember(ctx context.Context, username string, member Member) error

func (*Accounts) CreateDev added in v1.0.0

func (a *Accounts) CreateDev(ctx context.Context, username, email string) (*Account, error)

func (*Accounts) CreateOrg added in v1.0.0

func (a *Accounts) CreateOrg(ctx context.Context, name string, members []Member) (*Account, error)

func (*Accounts) Delete added in v1.0.0

func (a *Accounts) Delete(ctx context.Context, key crypto.PubKey) error

func (*Accounts) Get added in v1.0.0

func (a *Accounts) Get(ctx context.Context, key crypto.PubKey) (*Account, error)

func (*Accounts) GetByUsername added in v1.0.0

func (a *Accounts) GetByUsername(ctx context.Context, username string) (*Account, error)

func (*Accounts) GetByUsernameOrEmail added in v1.0.0

func (a *Accounts) GetByUsernameOrEmail(ctx context.Context, usernameOrEmail string) (*Account, error)

func (*Accounts) IsMember added in v1.0.0

func (a *Accounts) IsMember(ctx context.Context, username string, member crypto.PubKey) (bool, error)

func (*Accounts) IsNameAvailable added in v1.0.0

func (a *Accounts) IsNameAvailable(ctx context.Context, name string) (s string, err error)

func (*Accounts) IsOwner added in v1.0.0

func (a *Accounts) IsOwner(ctx context.Context, username string, member crypto.PubKey) (bool, error)

func (*Accounts) IsUsernameAvailable added in v1.0.0

func (a *Accounts) IsUsernameAvailable(ctx context.Context, username string) error

func (*Accounts) ListByMember added in v1.0.2

func (a *Accounts) ListByMember(ctx context.Context, member crypto.PubKey) ([]Account, error)

func (*Accounts) ListByOwner added in v1.0.2

func (a *Accounts) ListByOwner(ctx context.Context, owner crypto.PubKey) ([]Account, error)

func (*Accounts) ListMembers added in v1.0.0

func (a *Accounts) ListMembers(ctx context.Context, members []Member) ([]Account, error)

func (*Accounts) RemoveMember added in v1.0.0

func (a *Accounts) RemoveMember(ctx context.Context, username string, member crypto.PubKey) error

func (*Accounts) SetToken added in v1.0.0

func (a *Accounts) SetToken(ctx context.Context, key crypto.PubKey, token thread.Token) error

func (*Accounts) ValidateUsername added in v1.0.0

func (a *Accounts) ValidateUsername(username string) error

type Archive added in v1.0.4

type Archive struct {
	Cid        []byte
	JobID      string
	JobStatus  int
	Aborted    bool
	AbortedMsg string
	FailureMsg string
	CreatedAt  int64
}

type Archives added in v1.0.4

type Archives struct {
	Current Archive
	History []Archive
}

type Collections

type Collections struct {
	Sessions *Sessions
	Accounts *Accounts
	Invites  *Invites

	Threads      *Threads
	APIKeys      *APIKeys
	IPNSKeys     *IPNSKeys
	FFSInstances *FFSInstances

	Users *Users
	// contains filtered or unexported fields
}

func NewCollections

func NewCollections(ctx context.Context, uri, dbName string, hub bool) (*Collections, error)

NewCollections gets or create store instances for active collections.

func (*Collections) Close added in v1.0.0

func (c *Collections) Close() error

type FFSInstance added in v1.0.4

type FFSInstance struct {
	BucketKey string `bson:"_id"`
	FFSToken  string
	Archives  Archives
}

type FFSInstances added in v1.0.4

type FFSInstances struct {
	// contains filtered or unexported fields
}

func NewFFSInstances added in v1.0.4

func NewFFSInstances(ctx context.Context, db *mongo.Database) (*FFSInstances, error)

func (*FFSInstances) Create added in v1.0.4

func (k *FFSInstances) Create(ctx context.Context, bucketKey, ffsToken string) error

func (*FFSInstances) Get added in v1.0.4

func (k *FFSInstances) Get(ctx context.Context, bucketKey string) (*FFSInstance, error)

func (*FFSInstances) Replace added in v1.0.4

func (k *FFSInstances) Replace(ctx context.Context, ffs *FFSInstance) error

type IPNSKey added in v1.0.0

type IPNSKey struct {
	Name      string
	Cid       string
	ThreadID  thread.ID
	CreatedAt time.Time
}

type IPNSKeys added in v1.0.0

type IPNSKeys struct {
	// contains filtered or unexported fields
}

func NewIPNSKeys added in v1.0.0

func NewIPNSKeys(ctx context.Context, db *mongo.Database) (*IPNSKeys, error)

func (*IPNSKeys) Create added in v1.0.0

func (k *IPNSKeys) Create(ctx context.Context, name, cid string, threadID thread.ID) error

func (*IPNSKeys) Delete added in v1.0.0

func (k *IPNSKeys) Delete(ctx context.Context, name string) error

func (*IPNSKeys) Get added in v1.0.0

func (k *IPNSKeys) Get(ctx context.Context, name string) (*IPNSKey, error)

func (*IPNSKeys) GetByCid added in v1.0.0

func (k *IPNSKeys) GetByCid(ctx context.Context, cid string) (*IPNSKey, error)

func (*IPNSKeys) ListByThreadID added in v1.0.2

func (k *IPNSKeys) ListByThreadID(ctx context.Context, threadID thread.ID) ([]IPNSKey, error)

type Invite

type Invite struct {
	Token     string
	Org       string
	From      crypto.PubKey
	EmailTo   string
	Accepted  bool
	ExpiresAt time.Time
}

type Invites

type Invites struct {
	// contains filtered or unexported fields
}

func NewInvites added in v1.0.0

func NewInvites(ctx context.Context, db *mongo.Database) (*Invites, error)

func (*Invites) Accept added in v1.0.0

func (i *Invites) Accept(ctx context.Context, token string) error

func (*Invites) Create

func (i *Invites) Create(ctx context.Context, from crypto.PubKey, org, emailTo string) (*Invite, error)

func (*Invites) Delete

func (i *Invites) Delete(ctx context.Context, token string) error

func (*Invites) DeleteByFrom added in v1.0.2

func (i *Invites) DeleteByFrom(ctx context.Context, from crypto.PubKey) error

func (*Invites) DeleteByFromAndOrg added in v1.0.2

func (i *Invites) DeleteByFromAndOrg(ctx context.Context, from crypto.PubKey, org string) error

func (*Invites) DeleteByOrg added in v1.0.2

func (i *Invites) DeleteByOrg(ctx context.Context, org string) error

func (*Invites) Get

func (i *Invites) Get(ctx context.Context, token string) (*Invite, error)

func (*Invites) ListByEmail added in v1.0.2

func (i *Invites) ListByEmail(ctx context.Context, email string) ([]Invite, error)

type Member added in v1.0.0

type Member struct {
	Key      crypto.PubKey
	Username string
	Role     Role
}

type Role added in v1.0.0

type Role int
const (
	OrgOwner Role = iota
	OrgMember
)

func (Role) String added in v1.0.0

func (r Role) String() (s string)

type Session

type Session struct {
	ID        string
	Owner     crypto.PubKey
	ExpiresAt time.Time
}

func SessionFromContext added in v1.0.0

func SessionFromContext(ctx context.Context) (*Session, bool)

type Sessions

type Sessions struct {
	// contains filtered or unexported fields
}

func NewSessions added in v1.0.0

func NewSessions(ctx context.Context, db *mongo.Database) (*Sessions, error)

func (*Sessions) Create

func (s *Sessions) Create(ctx context.Context, owner crypto.PubKey) (*Session, error)

func (*Sessions) Delete

func (s *Sessions) Delete(ctx context.Context, id string) error

func (*Sessions) DeleteByOwner added in v1.0.2

func (s *Sessions) DeleteByOwner(ctx context.Context, owner crypto.PubKey) error

func (*Sessions) Get

func (s *Sessions) Get(ctx context.Context, id string) (*Session, error)

func (*Sessions) Touch

func (s *Sessions) Touch(ctx context.Context, id string) error

type Thread added in v1.0.0

type Thread struct {
	ID        thread.ID
	Owner     crypto.PubKey
	Name      string
	Key       string
	IsDB      bool
	CreatedAt time.Time
}

type Threads added in v1.0.0

type Threads struct {
	// contains filtered or unexported fields
}

func NewThreads added in v1.0.0

func NewThreads(ctx context.Context, db *mongo.Database) (*Threads, error)

func (*Threads) Create added in v1.0.0

func (t *Threads) Create(ctx context.Context, id thread.ID, owner crypto.PubKey, isDB bool) (*Thread, error)

func (*Threads) Delete added in v1.0.0

func (t *Threads) Delete(ctx context.Context, id thread.ID, owner crypto.PubKey) error

func (*Threads) DeleteByOwner added in v1.0.2

func (t *Threads) DeleteByOwner(ctx context.Context, owner crypto.PubKey) error

func (*Threads) Get added in v1.0.0

func (t *Threads) Get(ctx context.Context, id thread.ID, owner crypto.PubKey) (*Thread, error)

func (*Threads) GetByName added in v1.0.0

func (t *Threads) GetByName(ctx context.Context, name string, owner crypto.PubKey) (*Thread, error)

func (*Threads) ListByKey added in v1.0.0

func (t *Threads) ListByKey(ctx context.Context, key string) ([]Thread, error)

func (*Threads) ListByOwner added in v1.0.2

func (t *Threads) ListByOwner(ctx context.Context, owner crypto.PubKey) ([]Thread, error)

type User

type User struct {
	Key       crypto.PubKey
	CreatedAt time.Time
}

func UserFromContext added in v1.0.0

func UserFromContext(ctx context.Context) (*User, bool)

type Users

type Users struct {
	// contains filtered or unexported fields
}

func NewUsers added in v1.0.0

func NewUsers(_ context.Context, db *mongo.Database) (*Users, error)

func (*Users) Create added in v1.0.0

func (u *Users) Create(ctx context.Context, key crypto.PubKey) error

func (*Users) Delete

func (u *Users) Delete(ctx context.Context, key crypto.PubKey) error

func (*Users) Get

func (u *Users) Get(ctx context.Context, key crypto.PubKey) (*User, error)

Jump to

Keyboard shortcuts

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