chatroom

package
v0.0.0-...-0864d54 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatMsg

type ChatMsg struct {
	ID         string    `json:"id" bson:"_id,omitempty"`
	Message    string    `json:"message" bson:"message,omitempty" validate:"required"`
	SenderName string    `json:"senderName" bson:"senderName,omitempty" validate:"required"`
	TimeSent   time.Time `json:"timeSent" bson:"timeSent,omitempty" validate:"required"`
}

func (*ChatMsg) Validate

func (entity *ChatMsg) Validate() error

type ChatRoom

type ChatRoom struct {
	ID         string    `json:"id" bson:"_id,omitempty"`
	Name       string    `json:"name" bson:"name,omitempty" validate:"required"`
	RoomPin    string    `json:"roomPin" bson:"roomPin,omitempty" validate:"required,min=30"`
	InviteCode string    `json:"inviteCode" bson:"inviteCode,omitempty"`
	URL        string    `json:"url" bson:"url,omitempty" validate:"required,min=20"`
	TimeAdded  time.Time `json:"timeAdded" bson:"timeAdded,omitempty" validate:"required"`
	Chats      []ChatMsg `json:"chats" bson:"chats,omitempty"`
}

func (*ChatRoom) Validate

func (entity *ChatRoom) Validate() error

type ChatRoomRepo

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

func NewRepository

func NewRepository(db *mongo.Database) *ChatRoomRepo

NewRepository returns a new chatroom repository object that implements the Repository interface.

func (*ChatRoomRepo) SaveChatRoom

func (repo *ChatRoomRepo) SaveChatRoom(chatRoom *ChatRoom) error

SaveChatRoom saves a chat room to the database.

func (*ChatRoomRepo) SaveMessage

func (repo *ChatRoomRepo) SaveMessage(chatRoomID string, msg *ChatMsg) error

SaveMessage adds a message to a chatroom.

type Repository

type Repository interface {
	SaveChatRoom(chatRoom *ChatRoom) error
	SaveMessage(chatRoomID string, msg *ChatMsg) error
}

Repository is the interface that describes a chatroom repository object.

Jump to

Keyboard shortcuts

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