state

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Errors         = errorx.NewNamespace("States")
	ErrRateLimited = Errors.NewType("RateLimited")
)

Functions

This section is empty.

Types

type Account added in v0.18.0

type Account struct {
	Login                string       `firestore:"login"`
	Password             string       `firestore:"password"`
	Token                string       `firestore:"token"`
	RateLimitedUntil     time.Time    `firestore:"rateLimitedUntil"`
	RateLimitNextDayTime time.Time    `firestore:"rateLimitNextDayTime"`
	State                AccountState `firestore:"state"`
}

func (*Account) GetStateName added in v1.4.0

func (a *Account) GetStateName() (string, error)

type AccountState added in v0.18.0

type AccountState string
const (
	AccountStateEnabled  AccountState = "enabled"
	AccountStateDisabled AccountState = "disabled"
)

type FirebaseStates added in v0.3.0

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

func NewFirebaseState added in v0.20.0

func NewFirebaseState(logger *zap.Logger, storage *firestore.Client) *FirebaseStates

func (*FirebaseStates) GetAllStates added in v1.8.0

func (f *FirebaseStates) GetAllStates() ([]*UserState, error)

func (*FirebaseStates) GetState added in v0.3.0

func (f *FirebaseStates) GetState(userId int64) (*UserState, error)

func (*FirebaseStates) SetState added in v0.3.0

func (f *FirebaseStates) SetState(state *UserState) error

type FormField added in v0.18.0

type FormField string
const (
	FormFieldLogin               FormField = "login"
	FormFieldCurrentCategoryNode FormField = "currentCategoryNode"
	FormFieldMessageText         FormField = "messageText"
	FormFieldFiles               FormField = "files"
	FormFieldMessageIdFile       FormField = "messageIdFile"
)

type States

type States interface {
	// GetState Reads a user from the storage
	GetState(userId int64) (*UserState, error)
	// SetState Puts a new user into the storage. If the user already exists in the context, it's kept,
	SetState(state *UserState) error
	// GetAllStates Reads all users from the storage
	GetAllStates() ([]*UserState, error)
}

type UserState

type UserState struct {
	UserId             int64          `firestore:"userId"`
	FullName           string         `firestore:"fullName"`
	Accounts           []Account      `firestore:"accounts"`
	MessageHandlerName string         `firestore:"messageHandlerName"`
	SentMessagesCount  int            `firestore:"sentMessagesCount"`
	LastAccessAt       time.Time      `firestore:"lastAccessAt"`
	Form               map[string]any `firestore:"form"`
	Categories         string         `firestore:"categories"`
	// contains filtered or unexported fields
}

func (*UserState) AddValueToStringSlice added in v0.18.0

func (s *UserState) AddValueToStringSlice(key FormField, value string)

func (*UserState) ClearForm added in v0.18.0

func (s *UserState) ClearForm()

func (*UserState) GetIntFormField added in v0.18.0

func (s *UserState) GetIntFormField(key FormField) int

func (*UserState) GetStringFormField added in v0.18.0

func (s *UserState) GetStringFormField(key FormField) string

func (*UserState) GetStringMap added in v1.5.0

func (s *UserState) GetStringMap(key FormField) map[string]string

func (*UserState) GetStringSlice added in v0.18.0

func (s *UserState) GetStringSlice(key FormField) []string

func (*UserState) PutValueToMap added in v1.5.0

func (s *UserState) PutValueToMap(key FormField, valueKey string, value string)

func (*UserState) RemoveValueFromStringSlice added in v1.5.0

func (s *UserState) RemoveValueFromStringSlice(key FormField, value string)

func (*UserState) SetFormField added in v0.18.0

func (s *UserState) SetFormField(key FormField, value any)

Jump to

Keyboard shortcuts

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