usecases

package
v0.0.0-...-ef566a4 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2014 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Registration
	ErrUserAlreadyExists   = errors.New("Username unavailable")
	ErrInvalidRegisterInfo = errors.New("Invalid registration info")

	// Invalid ids
	ErrInvalidChannelId = errors.New("Invalid channel id")
	ErrInvalidClientId  = errors.New("Invalid client id")

	// Others
	ErrAccessDenied = errors.New("Access denied")
	ErrNoChannel    = errors.New("User is not in any channel")
)

Functions

This section is empty.

Types

type AuthentificationInteractor

type AuthentificationInteractor struct {
	UserRepository UserRepository
	Crypto         Crypto
	Logger         Logger
	// contains filtered or unexported fields
}

AuthentificationInteractor use cases for authentification

func NewAuthentificationInteractor

func NewAuthentificationInteractor(userRepository UserRepository, crypto Crypto, logger Logger) *AuthentificationInteractor

NewAuthentificationInteractor ctor

func (*AuthentificationInteractor) GoogleLogin

func (ai *AuthentificationInteractor) GoogleLogin(info *GoogleRegisterInfo) (*User, error)

GoogleLogin logs the user using google+ profile

func (*AuthentificationInteractor) Login

func (ai *AuthentificationInteractor) Login(info *LoginInfo) (*User, error)

Login logs in the user

func (*AuthentificationInteractor) Register

func (ai *AuthentificationInteractor) Register(info *RegisterInfo) (*User, error)

Register registers the user

type ChatInteractor

type ChatInteractor struct {
	ServerRepository  domain.ServerRepository
	ChannelRepository domain.ChannelRepository
	MessageRepository domain.MessageRepository
	ClientRepository  domain.ClientRepository
	Logger            Logger
	// contains filtered or unexported fields
}

func NewChatInteractor

func NewChatInteractor(serverRepo domain.ServerRepository, channelRepo domain.ChannelRepository,
	msgRepo domain.MessageRepository, clientRepo domain.ClientRepository, logger Logger) *ChatInteractor

func (*ChatInteractor) Channels

func (ci *ChatInteractor) Channels(clientId int64) (map[int64]*domain.Channel, int64, error)

func (*ChatInteractor) CreateChannel

func (ci *ChatInteractor) CreateChannel(clientId int64, name string) error

func (*ChatInteractor) Disconnect

func (ci *ChatInteractor) Disconnect(clientId int64) error

func (*ChatInteractor) GetMessages

func (ci *ChatInteractor) GetMessages(channelId int64) ([]*domain.Message, error)

func (*ChatInteractor) JoinChannel

func (ci *ChatInteractor) JoinChannel(clientId int64, channelId int64) error

func (*ChatInteractor) JoinServer

func (ci *ChatInteractor) JoinServer(clientId int64) (*domain.Client, error)

func (*ChatInteractor) SendMessage

func (ci *ChatInteractor) SendMessage(clientId int64, body string) error

type Crypto

type Crypto interface {
	CompareHashAndPassword(hash string, password string) (bool, error)
	GenerateFromPassword(password string) (string, error)
}

Crypto interfaces a crypto handler

type GoogleRegisterInfo

type GoogleRegisterInfo struct {
	Id          string
	DisplayName string
	FirstName   string
	LastName    string
	Email       string
}

GoogleRegisterInfo info for google login/registration

type HomeInteractor

type HomeInteractor struct {
	ClientRepository domain.ClientRepository
	Logger           Logger
}

func NewHomeInteractor

func NewHomeInteractor(clientRepository domain.ClientRepository, logger Logger) *HomeInteractor

func (*HomeInteractor) GetClient

func (hi *HomeInteractor) GetClient(clientId int64) (*domain.Client, error)

type Logger

type Logger interface {
	Log(message string)
	Error(err error)
}

type LoginInfo

type LoginInfo struct {
	Username string
	Password string
}

LoginInfo info for normal login

type RegisterInfo

type RegisterInfo struct {
	Username  string
	Password  string
	FirstName string
	LastName  string
	Email     string
}

RegisterInfo info used during registration

type User

type User struct {
	Id       int64
	Username string
	Client   *domain.Client
}

User represents an authentified user

type UserRepository

type UserRepository interface {
	Create(info *RegisterInfo) (*User, error)
	CreateGoogle(info *GoogleRegisterInfo) (*User, error)
	FindByName(name string) (*User, error)
	FindByNameWithHash(name string) (*User, string, error)
	FindByGoogleId(id string) (*User, error)
	UpdatePasswordHash(user *User, hash string) error
}

UserRepository interfaces a user repo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳