controller

package
v0.0.0-...-077edd7 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	User
	Subscription
	Info
}

Controller struct is used to access database

func NewController

func NewController(stg *storage.Storage) *Controller

NewController constructor of Controller

type Info

type Info interface {
	GetLastTimestamp() uint64    // Returns time of the latest post
	SetLastTimestamp(tsp uint64) // Sets time of the latest post
}

Info interface definces methods for Info Controller

type InfoController

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

InfoController is an implementation of controller.Info

func NewInfoController

func NewInfoController(stg *storage.Storage) *InfoController

NewInfoController constructor of InfoController struct

func (*InfoController) GetLastTimestamp

func (icon *InfoController) GetLastTimestamp() uint64

GetLastTimestamp returns time of the latest post

func (*InfoController) SetLastTimestamp

func (icon *InfoController) SetLastTimestamp(tsp uint64)

SetLastTimestamp sets time of the latest post

type Subscription

type Subscription interface {
	AddNew(chatID int64, request string) error // Adds new subscription to user with publication
	Create(chatID int64, request string) error
	Remove(chatID int64, request string) error                 // Removes existing sybscription from user
	Update(chatID int64, request string) error                 // Updates selected subscription
	GetSubsByChatID(chatID int64) ([]logic.Publication, error) // Returns all user's subs
	GetAllSubs() []logic.Publication                           // Returns all publications
	GetAllDefaultSubs() []logic.Publication
	RemoveDefault(chatID int64, request string) error
	Subscribe(chatID int64, request string) error
}

Subscription interface defines methods for Publication Controller

type SubscriptionController

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

SubscriptionController is an implementation of controller.Subscription

func NewSubscriptionController

func NewSubscriptionController(stg *storage.Storage) *SubscriptionController

NewSubscriptionController constructor of SubscriptionController struct

func (*SubscriptionController) AddNew

func (scon *SubscriptionController) AddNew(chatID int64, request string) error

AddNew creates a subscription to user with publication

func (*SubscriptionController) Create

func (scon *SubscriptionController) Create(chatID int64, request string) error

Create default subscribtion

func (*SubscriptionController) GetAllDefaultSubs

func (scon *SubscriptionController) GetAllDefaultSubs() []logic.Publication

GetAllDefaultSubs returns all default publications

func (*SubscriptionController) GetAllSubs

func (scon *SubscriptionController) GetAllSubs() []logic.Publication

GetAllSubs returns all publications

func (*SubscriptionController) GetSubsByChatID

func (scon *SubscriptionController) GetSubsByChatID(chatID int64) ([]logic.Publication, error)

GetSubsByChatID returns all user's subs

func (*SubscriptionController) Remove

func (scon *SubscriptionController) Remove(chatID int64, request string) error

Remove existing sybscription from user

func (*SubscriptionController) RemoveDefault

func (scon *SubscriptionController) RemoveDefault(chatID int64, request string) error

RemoveDefault deletes default publication

func (*SubscriptionController) Subscribe

func (scon *SubscriptionController) Subscribe(chatID int64, request string) error

Subscribe user to publication

func (*SubscriptionController) Update

func (scon *SubscriptionController) Update(chatID int64, request string) error

Update selected subscription May be used in future updates

type User

type User interface {
	Register(chatID int64) error                                        // Performs user registration
	Unregister(chatID int64) error                                      // Performs user deregistration
	GetUsersByPublication(pub *logic.Publication) ([]logic.User, error) // Returns owner of publication
}

User interface defines methods for User Controller

type UserController

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

UserController is an implementation of controller.User

func NewUserController

func NewUserController(stg *storage.Storage) *UserController

NewUserController constructor of UserController struct

func (*UserController) GetUsersByPublication

func (ucon *UserController) GetUsersByPublication(pub *logic.Publication) ([]logic.User, error)

GetUsersByPublication returns subscribers of publication

func (*UserController) Register

func (ucon *UserController) Register(chatID int64) error

Register performs user registration

func (*UserController) Unregister

func (ucon *UserController) Unregister(chatID int64) error

Unregister performs user deregistration

Directories

Path Synopsis
Package mock_storage is a generated GoMock package.
Package mock_storage is a generated GoMock package.

Jump to

Keyboard shortcuts

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