Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChatDB ¶
type ChatDB interface { Add(chatname string) error Remove(chatname string) error GetChats() []string AddUser(chatname, username string) error RemoveUser(chatname, username string) error IsInChat(chatname, username string) bool GetUsers(chatname string) []string }
ChatDB stores chats in-memory
type ChatReport ¶
type ChatReport struct { models.User models.Chat Joined bool `json:"joined"` Messages []*models.Message `json:"messages"` Users []models.UserWithStatus `json:"users"` }
ChatReport ...
func NewChatReport ¶
func NewChatReport(username, chatname string, joined bool) ChatReport
NewChatReport ...
type LoggedDB ¶
type LoggedDB interface { // Login must return valid *User if (error == ErrAlreadyLogged) // with other errors must return (nil, err) // also should generate valid LoginToken and LastActivity Login(username string) (*models.LoggedUser, error) Update(*models.LoggedUser) error Get(username string) (*models.LoggedUser, error) Logout(username string) error GetLoggedUsers() []string }
LoggedDB represents logged users
type MessageDB ¶
type MessageDB interface { // should update message ID and time Post(*models.Message) error // should return empty slice even on error GetLastNMessages(chatname string, n int) ([]*models.Message, error) }
MessageDB ...
type Store ¶
Store contains all databases
func (*Store) MakeChatReportForUser ¶
func (s *Store) MakeChatReportForUser(username string, chatname string) ChatReport
MakeChatReportForUser returns ChatReport for an user. If not joined, Messages and Users fields are always empty. Chat should be locked. LoggedDB, MessageDB should be unlocked.
Click to show internal directories.
Click to hide internal directories.