multidevice

package
v0.28.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: MPL-2.0 Imports: 5 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 {
	MaxInstallations int
	ProtocolVersion  uint32
	InstallationID   string
}

type Installation

type Installation struct {
	// Identity is the string identity of the owner
	Identity string `json:"identity"`
	// The installation-id of the device
	ID string `json:"id"`
	// The last known protocol version of the device
	Version uint32 `json:"version"`
	// Enabled is whether the installation is enabled
	Enabled bool `json:"enabled"`
	// Timestamp is the last time we saw this device
	Timestamp int64 `json:"timestamp"`
	// InstallationMetadata
	InstallationMetadata *InstallationMetadata `json:"metadata"`
}

type InstallationMetadata

type InstallationMetadata struct {
	// The name of the device
	Name string `json:"name"`
	// The type of device
	DeviceType string `json:"deviceType"`
	// The FCMToken for mobile devices
	FCMToken string `json:"fcmToken"`
}

type Persistence

type Persistence interface {
	// GetActiveInstallations returns the active installations for a given identity.
	GetActiveInstallations(maxInstallations int, identity []byte) ([]*Installation, error)
	// EnableInstallation enables the installation.
	EnableInstallation(identity []byte, installationID string) error
	// DisableInstallation disable the installation.
	DisableInstallation(identity []byte, installationID string) error
	// AddInstallations adds the installations for a given identity, maintaining the enabled flag
	AddInstallations(identity []byte, timestamp int64, installations []*Installation, defaultEnabled bool) ([]*Installation, error)
	// GetInstallations returns all the installations for a given identity
	GetInstallations(identity []byte) ([]*Installation, error)
	// SetInstallationMetadata sets the metadata for a given installation
	SetInstallationMetadata(identity []byte, installationID string, data *InstallationMetadata) error
}

type SQLLitePersistence

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

SQLLitePersistence represents a persistence service tied to an SQLite database

func NewSQLLitePersistence

func NewSQLLitePersistence(db *sql.DB) *SQLLitePersistence

NewSQLLitePersistence creates a new SQLLitePersistence instance, given a path and a key

func (*SQLLitePersistence) AddInstallations

func (s *SQLLitePersistence) AddInstallations(identity []byte, timestamp int64, installations []*Installation, defaultEnabled bool) ([]*Installation, error)

AddInstallations adds the installations for a given identity, maintaining the enabled flag

func (*SQLLitePersistence) DisableInstallation

func (s *SQLLitePersistence) DisableInstallation(identity []byte, installationID string) error

DisableInstallation disable the installation

func (*SQLLitePersistence) EnableInstallation

func (s *SQLLitePersistence) EnableInstallation(identity []byte, installationID string) error

EnableInstallation enables the installation

func (*SQLLitePersistence) GetActiveInstallations

func (s *SQLLitePersistence) GetActiveInstallations(maxInstallations int, identity []byte) ([]*Installation, error)

GetActiveInstallations returns the active installations for a given identity

func (*SQLLitePersistence) GetInstallations

func (s *SQLLitePersistence) GetInstallations(identity []byte) ([]*Installation, error)

GetInstallations returns all the installations for a given identity we both return the installations & the metadata

func (*SQLLitePersistence) SetInstallationMetadata

func (s *SQLLitePersistence) SetInstallationMetadata(identity []byte, installationID string, metadata *InstallationMetadata) error

SetInstallationMetadata sets the metadata for a given installation

type Service

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

func New

func New(config *Config, persistence Persistence) *Service

func (*Service) DisableInstallation

func (s *Service) DisableInstallation(myIdentityKey *ecdsa.PublicKey, installationID string) error

func (*Service) EnableInstallation

func (s *Service) EnableInstallation(identity *ecdsa.PublicKey, installationID string) error

func (*Service) GetActiveInstallations

func (s *Service) GetActiveInstallations(identity *ecdsa.PublicKey) ([]*Installation, error)

func (*Service) GetOurActiveInstallations

func (s *Service) GetOurActiveInstallations(identity *ecdsa.PublicKey) ([]*Installation, error)

func (*Service) GetOurInstallations

func (s *Service) GetOurInstallations(identity *ecdsa.PublicKey) ([]*Installation, error)

func (*Service) ProcessPublicBundle

func (s *Service) ProcessPublicBundle(myIdentityKey *ecdsa.PrivateKey, theirIdentity *ecdsa.PublicKey, b *protobuf.Bundle) ([]*Installation, error)

ProcessPublicBundle persists a bundle and returns a list of tuples identity/installationID

func (*Service) SetInstallationMetadata

func (s *Service) SetInstallationMetadata(identity *ecdsa.PublicKey, installationID string, metadata *InstallationMetadata) error

Jump to

Keyboard shortcuts

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