tg

package
v0.0.0-...-4f702ff Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadParams error = errors.New("Bad params.")

ErrBadRequest is error for case when bad request

View Source
var ErrBadRequest error = errors.New("Bad request.")

ErrBadRequest is error for case when bad request

View Source
var ErrInternal error = errors.New("Internal error.")

ErrInternal is error for case when smth went wrong

View Source
var ErrNotFound error = errors.New("Not found.")

ErrNotFound is error for case when entity not found

View Source
var ErrPasswordAuthNeeded error = errors.New("Password auth needed.")
View Source
var ErrSignUpRequired error = errors.New("Sign up required.")
View Source
var ErrUserEmpty error = errors.New("User is empty.")

Functions

func New

func New(config *Config, logger log.Logger, sessionRepository SessionRepository) *service

Types

type Application

type Application struct {
	Title           string
	ShortName       string
	AppID           int
	AppHash         string
	ServerHost      string
	PublicKeyFile   string
	InitWarnChannel bool
}

type Config

type Config struct {
	Application Application
}

type Service

type Service interface {
	IsAuth(ctx context.Context, sessionID string) (bool, error)
	SendCode(ctx context.Context, sessionID string, phone string) error
	SignIn(ctx context.Context, sessionID string, code string, password string) (*tg.User, error)
}

type Session

type Session struct {
	IsAuthorized  bool
	Session       []byte
	ID            string
	PhoneCodeHash string
	Phone         string
}

func NewSession

func NewSession(ID string) *Session

type SessionRepository

type SessionRepository interface {
	Get(ctx context.Context, ID string) (*Session, error)
	Set(ctx context.Context, entity *Session) error
	Delete(ctx context.Context, ID string) error
}

type SessionRepositoryCreater

type SessionRepositoryCreater func(sessionID string) SessionRepository

type SessionStorage

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

func NewSessionStorage

func NewSessionStorage(repository SessionRepository, sessionID string) *SessionStorage

func (*SessionStorage) LoadSession

func (s *SessionStorage) LoadSession(ctx context.Context) ([]byte, error)

func (*SessionStorage) StoreSession

func (s *SessionStorage) StoreSession(ctx context.Context, data []byte) error

Jump to

Keyboard shortcuts

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