model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HubConstruct = hub{
	// contains filtered or unexported fields
}
View Source
var Upgrader = websocket.Upgrader{
	ReadBufferSize:  1024,
	WriteBufferSize: 1024,
}

Functions

func InitDB

func InitDB()

Types

type CookieData

type CookieData struct {
	ExitTime time.Time
	UUID     string
	Email    string
}

type CookieDetail

type CookieDetail struct {
	Email      string
	Collection string
	CookieName string
	Path       string
	Data       CookieData
}

func (*CookieDetail) CheckCookie

func (b *CookieDetail) CheckCookie(r *http.Request) error

func (CookieDetail) GenerateCookie

func (b CookieDetail) GenerateCookie(w http.ResponseWriter) (string, error)

GenerateCookie generates a token and sends to frontend. Generated tokens are to be stored by frontend and verified for every request.

type Message

type Message struct {
	RoomID      string `bson:"roomID" json:"roomID,omitempty"`
	Message     string `bson:"message" json:"message,omitempty"`
	UserID      string `bson:"userID" json:"userID,omitempty"`
	Name        string `bson:"name" json:"name,omitempty"`
	Time        string `bson:"time" json:"time,omitempty"`
	Type        string `bson:"type" json:"type,omitempty"`
	Size        string `bson:"size,omitempty" json:"size,omitempty"`
	Hash        string `bson:"hash,omitempty" json:"hash,omitempty"`
	Index       int    `bson:"index" json:"index,omitempty"`
	MessageType string `bson:"-" json:"msgType,omitempty"`
}

Message struct defines user message contents, size and hash is defined if user is sending files. Index is used to track message count as to Rooms messages, this should help with partitioning if we are to retrieve message of a particular count.

type User

type User struct {
	Email string `bson:"_id" json:"userID"`
	Name  string `bson:"name" json:"name"`
	DOB   string `bson:"age" json:"age"`
	Class string `bson:"class" json:"class"`
	// ID should either be users matric or leading email stripping @....
	Password         []byte        `bson:"password" json:"-"`
	PasswordInString string        `bson:"-" json:"password"`
	RoomsJoined      []roomsJoined `bson:"roomsJoined" json:"roomsJoined"`
	JoinRequest      []joinRequest `bson:"joinRequest" json:"joinRequest"`
	UUID             string        `bson:"loginUUID" json:"uuid"`
}

func (User) CreateUser

func (b User) CreateUser(r *http.Request) error

func (User) CreateUserLogin

func (b User) CreateUserLogin(password string, w http.ResponseWriter) (string, error)

Jump to

Keyboard shortcuts

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