model

package
v0.0.0-...-53c0529 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MessageNil = MessageID("")

Functions

func IsGroupExists

func IsGroupExists(db *db.DB, group GroupID) bool

func IsUserInGroup

func IsUserInGroup(db *db.DB, user UserID, group GroupID) bool

Types

type Group

type Group struct {
	ID          GroupID   `json:"id"`
	Admin       UserID    `json:"admin"`
	LastMessage MessageID `json:"last_message"`
	// contains filtered or unexported fields
}

func CreateNewGroup

func CreateNewGroup(db *db.DB, user UserID, id GroupID) *Group

func GetGroup

func GetGroup(db *db.DB, groupID GroupID) *Group

func (Group) GetAdmin

func (group Group) GetAdmin() UserID

func (Group) GetID

func (group Group) GetID() GroupID

func (Group) GetLastMessage

func (group Group) GetLastMessage() MessageID

func (*Group) Save

func (group *Group) Save()

func (*Group) SetLastMessage

func (group *Group) SetLastMessage(messageID MessageID) *Group

type GroupID

type GroupID string

type InGroup

type InGroup struct {
	User  UserID  `json:"user"`
	Group GroupID `json:"group"`

	LastRead Timestamp `json:"last_read"`
	// contains filtered or unexported fields
}

func CreateNewInGroup

func CreateNewInGroup(db *db.DB, user UserID, group GroupID) *InGroup

func GetInGroup

func GetInGroup(db *db.DB, user UserID, group GroupID) *InGroup

func (InGroup) Delete

func (inGroup InGroup) Delete()

func (InGroup) GetTimestamp

func (inGroup InGroup) GetTimestamp() Timestamp

func (InGroup) Save

func (inGroup InGroup) Save()

func (*InGroup) UpdateLastRead

func (inGroup *InGroup) UpdateLastRead(timestamp Timestamp) *InGroup

type Message

type Message struct {
	ID        MessageID   `json:"id"`
	Group     GroupID     `json:"group"`
	User      UserID      `json:"user"`
	Message   MessageType `json:"message"`
	Time      string      `json:"time"`
	Timestamp Timestamp   `json:"timestamp"`

	PrevID MessageID `json:"prevID"`
	// contains filtered or unexported fields
}

func CreateNewMessage

func CreateNewMessage(db *db.DB, user UserID, group GroupID, message MessageType, time string) *Message

func GetMessage

func GetMessage(db *db.DB, msgID MessageID) *Message

func (*Message) GenerateID

func (message *Message) GenerateID(seed Timestamp) *Message

func (Message) GetGroup

func (message Message) GetGroup() GroupID

func (Message) GetID

func (message Message) GetID() MessageID

func (Message) GetMessage

func (message Message) GetMessage() MessageType

func (Message) GetPrevMessageID

func (message Message) GetPrevMessageID() MessageID

func (Message) GetTime

func (message Message) GetTime() string

func (Message) GetTimestamp

func (message Message) GetTimestamp() Timestamp

func (Message) GetUser

func (message Message) GetUser() UserID

func (*Message) Save

func (message *Message) Save()

func (*Message) SetPrevID

func (message *Message) SetPrevID(messageID MessageID) *Message

func (*Message) SetTimestamp

func (message *Message) SetTimestamp(timestamp Timestamp) *Message

func (Message) Validate

func (message Message) Validate() bool

type MessageID

type MessageID string

func GenerateNewMessageID

func GenerateNewMessageID(seed int) MessageID

func GetLastMessageID

func GetLastMessageID(db *db.DB, groupID GroupID) MessageID

func (MessageID) IsNull

func (id MessageID) IsNull() bool

type MessageType

type MessageType string

type Timestamp

type Timestamp int32

type User

type User struct {
	ID UserID `json:"id"`
	// contains filtered or unexported fields
}

func CreateNewUser

func CreateNewUser(db *db.DB, id UserID) *User

func GetUser

func GetUser(db *db.DB, id UserID) *User

func (User) GetID

func (user User) GetID() UserID

func (*User) Save

func (user *User) Save()

type UserID

type UserID string

Jump to

Keyboard shortcuts

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