service

package
v0.0.0-...-7dcd445 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DBPathCfgDir app directory (indexedDB, gormDB)
	DBPathCfgDir = "salty"

	// DBPathFileName database file name (gormDB)
	DBPathFileName = "salty.db"

	// DBPathAccountsDir contains all the user accounts (indexedDB)
	DBPathAccountsDir = "accounts"

	// DBPathCurrentAccountDir contains the current Account in the ui (indexedDB)
	DBPathCurrentAccountDir = "account"

	// DBPathContactsDir contains Account directory to which it belongs to and
	// then all the contacts inside that directory (indexedDB)
	DBPathContactsDir = "contacts"

	// DBPathMessagesDir contains Account directory which in turn
	// contains Contact directory to which it belongs to and
	// then all the messages inside that directory (indexedDB)
	DBPathMessagesDir = "messages"
)
View Source
const AppIndexedDBVersion int64 = 3
View Source
const AppLookupEndPoint = BaseURL + "/api/v1/lookup"
View Source
const AppRegisterEndPoint = "https://salty.mills.io"
View Source
const AppSendEndPoint = BaseURL + "/api/v1/send"
View Source
const BaseURL = "https://salty.mills.io"

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Addr     string `gorm:"primaryKey"`
	Avatar   []byte
	Contents []byte
	StateStr string
}

func (*Account) ConfigJSON

func (a *Account) ConfigJSON() (*ConfigJSON, error)

func (*Account) Register

func (a *Account) Register() <-chan error

func (*Account) SaltyClient

func (a *Account) SaltyClient() <-chan SaltyClient

type ConfigJSON

type ConfigJSON struct {
	Config saltyim.Config
	Hash   string
	User   string
	Domain string
}

type Contact

type Contact struct {
	CreatedAt   time.Time
	UpdatedAt   time.Time
	Addr        string     `gorm:"primaryKey"`
	AccountAddr string     `gorm:"primaryKey;foreignKey"`
	Messages    []*Message `gorm:"foreignKey:AccountAddr,ContactAddr;References:AccountAddr,Addr;constraint:OnDelete:CASCADE"`
	Avatar      []byte
	// contains filtered or unexported fields
}

type Message

type Message struct {
	ID          uuid.UUID `gorm:"type:uuid;primaryKey"`
	AccountAddr string    `gorm:"foreignKey;primaryKey"`
	ContactAddr string    `gorm:"foreignKey;primaryKey"`
	From        string
	To          string
	Created     string
	Text        string
	Key         string
	Hash        string
	Read        bool `gorm:"type:boolean;default:false;not null;"`
}

Message properties AccountAddr and ContactAddr keyConfigMessages

type PrimaryAccount

type PrimaryAccount struct {
	AlwaysOne   int `gorm:"primaryKey;check:always_one = 1"`
	AccountAddr string
}

type SaltyClient

type SaltyClient struct {
	*saltyim.Client
	// contains filtered or unexported fields
}

func (*SaltyClient) Error

func (e *SaltyClient) Error() error

type Service

type Service interface {
	Initialized() bool
	Account() Account
	Accounts() []Account
	Contacts() []Contact
	Messages(contactAddr string, offset int, limit int) <-chan []Message
	CreateIDFromAddrStr(addrStr string) <-chan error
	SendMessage(addrStr string, msg string, createdTimestamp string) <-chan error
	NewChat(addrStr string) <-chan error
	GetContactByAddrStr(addrStr string) Contact
	CreateIDFromBytes(bs []byte) <-chan error
	AccountAddrExist(addrStr string) bool
	AccountKeyExists(contents []byte) bool
	SetAsCurrentAccount(addrStr string) <-chan error
	Events() <-chan struct{}
	LastMessage(contactAddr string) <-chan Message
	DeleteAccounts([]Account) <-chan error
	DeleteContacts([]Contact) <-chan error
	UnreadMessagesCount(contactAddr string) <-chan int64
	MessagesCount(contactAddr string) <-chan int64
	MarkPrevMessagesAsRead(contactAddr string) <-chan error
}

func GetServiceInstance

func GetServiceInstance() Service

Jump to

Keyboard shortcuts

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