controller

package
v0.0.0-...-715658b Latest Latest
Warning

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

Go to latest
Published: May 8, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KEYS      = "keys"
	CONTACTS  = "contacts"
	USER      = "user"
	DOWNLOADS = "downloads"
	ERRORS    = "errors"
	STATUS    = "status"
)

Functions

func CreateGenericBuckets

func CreateGenericBuckets(db *bolt.DB) error

func CreateUserContactBucket

func CreateUserContactBucket(userBucket string, db *bolt.DB) error

attempts to create a bucket for a user to store contacts in

Types

type CONTROLLER

type CONTROLLER struct {
	SERVER            *srv.Server
	CRYPTO            *cryptography.Crypto
	User              *User
	UserAuthenticated func(user string, error string) //when oauth is complete can call this
	Contacts          *Contacts
	Logger            func(message string)
	SearchResults     *SearchResults
	Db                *bolt.DB
	DBPath            string
	DBDisabled        bool
	WebAssets         packr.Box
}

func (*CONTROLLER) AddContactToList

func (c *CONTROLLER) AddContactToList(p *Person)

func (*CONTROLLER) AddFileToContact

func (c *CONTROLLER) AddFileToContact(sender string, file utils.File) error

func (*CONTROLLER) Authorize

func (c *CONTROLLER) Authorize(apiKey string) (User, error)

func (*CONTROLLER) CheckForExistingUser

func (c *CONTROLLER) CheckForExistingUser() error

func (*CONTROLLER) CloseDb

func (c *CONTROLLER) CloseDb() error

func (*CONTROLLER) CreatePersonFromIdentifier

func (c *CONTROLLER) CreatePersonFromIdentifier(identifier string) *Person

func (*CONTROLLER) DeleteContactFromList

func (c *CONTROLLER) DeleteContactFromList(identifier string)

func (*CONTROLLER) DownloadFileFromContact

func (c *CONTROLLER) DownloadFileFromContact(pendingContact, pendingFile string) error

func (*CONTROLLER) GetDownloadedFiles

func (c *CONTROLLER) GetDownloadedFiles() ([]utils.File, error)

func (*CONTROLLER) InitialiseDatabase

func (c *CONTROLLER) InitialiseDatabase() error

func (*CONTROLLER) Logout

func (c *CONTROLLER) Logout(callback func())

func (*CONTROLLER) OpenDownloadedFile

func (c *CONTROLLER) OpenDownloadedFile(filePath string) error

func (*CONTROLLER) RemoveCurrentUser

func (c *CONTROLLER) RemoveCurrentUser() error

func (*CONTROLLER) RetrieveAllPeople

func (c *CONTROLLER) RetrieveAllPeople(userBucket string) ([]Person, error)

func (*CONTROLLER) RetrieveFilesForUser

func (c *CONTROLLER) RetrieveFilesForUser() error

func (*CONTROLLER) RetrievePerson

func (c *CONTROLLER) RetrievePerson(userBucket, userId string) (*Person, error)

func (*CONTROLLER) RetrieveUser

func (c *CONTROLLER) RetrieveUser() (*User, error)

func (*CONTROLLER) SearchForContacts

func (c *CONTROLLER) SearchForContacts(searchQuery string) ([]Person, error)

func (*CONTROLLER) StoreErrorMessage

func (c *CONTROLLER) StoreErrorMessage(message string, code int) error

func (*CONTROLLER) StorePerson

func (c *CONTROLLER) StorePerson(userBucket string, p *Person) error

func (*CONTROLLER) StoreStatusMessage

func (c *CONTROLLER) StoreStatusMessage(message string, code int) error

func (*CONTROLLER) StoreUser

func (c *CONTROLLER) StoreUser(u *User) error

func (*CONTROLLER) SyncPeople

func (c *CONTROLLER) SyncPeople() (map[string]*Person, error)

func (*CONTROLLER) UploadFileToContact

func (c *CONTROLLER) UploadFileToContact(pendingContact, pendingFile string) (string, error)

============================================================================================================================

func (*CONTROLLER) UserSpecificSetup

func (c *CONTROLLER) UserSpecificSetup(modify bool)

type Contacts

type Contacts struct {
	People map[string]*Person
	Len    int
}

type Error

type Error struct {
	Code    int
	Message string
	Time    time.Time
}

type Person

type Person struct {
	Name   string
	UserId string //email
	Files  map[string]*utils.File
	Len    int
	KeyId  int
}

type SearchResults

type SearchResults struct {
	Results []string
	Len     int
}

type Status

type Status struct {
	Code    int
	Message string
	Time    time.Time
}

type User

type User struct {
	UserId *uuid.UUID `json:"user_id"` //our id
	// Id        string     `json:"id"`      //a services id (e.g google)
	Username  string    `json:"username" gorm:"unique"`
	Email     string    `json:"-" gorm:"not null;unique"`
	Name      string    `json:"name"`
	Picture   string    `json:"picture"`
	Locale    string    `json:"-"`
	ApiKey    string    `json:"apiKey"`
	Service   string    `json:"service"`
	CreatedAt time.Time `json:"createdAt"`
	Verified  bool      `json:"verified"` //cannot send files just receive files if not verified (anonymous)
	// Expiry    time.Time `json:"expiry"`
	Enabled bool `json:"enabled"`
}

Jump to

Keyboard shortcuts

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