entity

package
v0.0.0-...-9cb16bd Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidMessageType

func IsValidMessageType(messageType string) bool

IsValidMessageType checks if the message type is valid

Types

type Message

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

Message is a struct that represents a message in a room

func NewMessage

func NewMessage(
	id string,
	roomID string,
	senderID string,
	content string,
	messageType MessageType,
	createdAt time.Time,
) *Message

NewMessage creates a new message

func (*Message) GetContent

func (m *Message) GetContent() string

GetContent returns the content of the message

func (*Message) GetCreatedAt

func (m *Message) GetCreatedAt() time.Time

GetCreatedAt returns the created at timestamp of the message

func (*Message) GetID

func (m *Message) GetID() string

GetID returns the id of the message

func (*Message) GetMessageType

func (m *Message) GetMessageType() MessageType

GetMessageType returns the message type of the message

func (*Message) GetRoomID

func (m *Message) GetRoomID() string

GetRoomID returns the room id of the message

func (*Message) GetSenderID

func (m *Message) GetSenderID() string

GetSenderID returns the sender id of the message

func (*Message) GetUpdatedAt

func (m *Message) GetUpdatedAt() *time.Time

GetUpdatedAt returns the updated at timestamp of the message

func (*Message) SetContent

func (m *Message) SetContent(content string)

SetContent sets the content of the message

func (*Message) SetCreatedAt

func (m *Message) SetCreatedAt(createdAt time.Time)

SetCreatedAt sets the created at timestamp of the message

func (*Message) SetID

func (m *Message) SetID(id string)

SetID sets the id of the message

func (*Message) SetMessageType

func (m *Message) SetMessageType(messageType MessageType)

SetMessageType sets the message type of the message

func (*Message) SetRoomID

func (m *Message) SetRoomID(roomID string)

SetRoomID sets the room id of the message

func (*Message) SetSenderID

func (m *Message) SetSenderID(senderID string)

SetSenderID sets the sender id of the message

func (*Message) SetUpdatedAt

func (m *Message) SetUpdatedAt(updatedAt *time.Time)

SetUpdatedAt sets the updated at timestamp of the message

type MessageType

type MessageType string
const (
	// text
	MessageTypeText MessageType = "text"
	// image
	MessageTypeImage MessageType = "image"
	// video
	MessageTypeVideo MessageType = "video"
	// audio
	MessageTypeAudio MessageType = "audio"
	// file
	MessageTypeFile MessageType = "file"
	// link
	MessageTypeLink MessageType = "link"
)

type Room

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

func NewRoom

func NewRoom(uuid string, meta RoomMeta, roomType RoomType, createdAt time.Time) *Room

NewRoom creates a new room entity

func (*Room) AddRoomUser

func (r *Room) AddRoomUser(user RoomUser)

AddRoomUser adds a room user to the room entity

func (*Room) CheckRoomUserExists

func (r *Room) CheckRoomUserExists(userID string) bool

CheckRoomUserExists checks if a room user exists in the room entity

func (*Room) GetCreatedAt

func (r *Room) GetCreatedAt() time.Time

GetCreatedAt returns the created at timestamp of the room entity

func (*Room) GetID

func (r *Room) GetID() string

ID returns the ID of the room entity

func (*Room) GetLastMessageAt

func (r *Room) GetLastMessageAt() *time.Time

GetLastMessageAt returns the last message timestamp of the room entity

func (*Room) GetLastMessageID

func (r *Room) GetLastMessageID() string

GetLastMessageID returns the last message ID of the room entity

func (*Room) GetRoomConfig

func (r *Room) GetRoomConfig() RoomConfig

GetRoomConfig returns the room config of the room entity

func (*Room) GetRoomMeta

func (r *Room) GetRoomMeta() RoomMeta

GetRoomMeta returns the room meta of the room entity

func (*Room) GetRoomUsers

func (r *Room) GetRoomUsers() []RoomUser

GetRoomUsers returns the room users of the room entity

func (*Room) GetUpdatedAt

func (r *Room) GetUpdatedAt() *time.Time

GetUpdatedAt returns the updated at timestamp of the room entity

func (*Room) RemoveRoomUser

func (r *Room) RemoveRoomUser(userID string)

RemoveRoomUser removes a room user from the room entity

func (*Room) SetCreatedAt

func (r *Room) SetCreatedAt(t time.Time)

SetCreatedAt sets the created at timestamp for the room entity

func (*Room) SetID

func (r *Room) SetID(id string)

SetID sets the ID of the room entity

func (*Room) SetLastMessage

func (r *Room) SetLastMessage(id string)

SetLastMessage sets the last message of the room entity

func (*Room) SetRoomConfig

func (r *Room) SetRoomConfig(config RoomConfig)

SetRoomConfig sets the room config of the room entity

func (*Room) SetRoomMeta

func (r *Room) SetRoomMeta(meta RoomMeta)

SetRoomMeta sets the room meta of the room entity

func (*Room) SetRoomUsers

func (r *Room) SetRoomUsers(users []RoomUser)

SetRoomUsers sets the room users of the room entity

func (*Room) SetUpdatedAt

func (r *Room) SetUpdatedAt(t *time.Time)

SetUpdatedAt sets the updated at timestamp for the room entity

type RoomConfig

type RoomConfig struct {
	RoomType RoomType `json:"room_type" bson:"room_type"`
}

func NewRoomConfig

func NewRoomConfig(roomType RoomType) *RoomConfig

NewRoomConfig creates a new RoomConfig TBD: make this configurable via env vars

func (*RoomConfig) SetRoomType

func (rc *RoomConfig) SetRoomType(roomType RoomType)

SetRoomType sets the room type

type RoomMeta

type RoomMeta struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

func NewRoomMeta

func NewRoomMeta(name string, description string) *RoomMeta

NewRoomMeta creates a new RoomMeta

func (*RoomMeta) SetDescription

func (r *RoomMeta) SetDescription(description string)

SetDescription sets the description of the entity

func (*RoomMeta) SetName

func (r *RoomMeta) SetName(name string)

SetName sets the name of the entity

type RoomType

type RoomType string
const (
	RoomTypeGroup   RoomType = "group"
	RoomTypePrivate RoomType = "private"
)

type RoomUser

type RoomUser struct {
	// User Details
	UserID string       `json:"user_id" bson:"user_id"`
	Role   RoomUserRole `json:"role" bson:"role"`

	// Status
	Status RoomUserStatus `json:"status" bson:"status"`

	// Booleans
	IsMuted bool `json:"is_muted" bson:"is_muted"`

	// Timestamps
	CreatedAt time.Time  `json:"created_at" bson:"created_at"`
	UpdatedAt *time.Time `json:"updated_at" bson:"updated_at"`
}

func NewRoomUser

func NewRoomUser(userID string, role RoomUserRole, createdAt time.Time) *RoomUser

NewRoomUser creates a new room user

func (*RoomUser) SetCreatedAt

func (r *RoomUser) SetCreatedAt(createdAt time.Time)

SetCreatedAt sets the created at

func (*RoomUser) SetIsMuted

func (r *RoomUser) SetIsMuted(isMuted bool)

SetIsMuted sets the is muted

func (*RoomUser) SetRole

func (r *RoomUser) SetRole(role RoomUserRole)

SetRole sets the role

func (*RoomUser) SetStatus

func (r *RoomUser) SetStatus(status RoomUserStatus)

SetStatus sets the status

func (*RoomUser) SetUpdatedAt

func (r *RoomUser) SetUpdatedAt(updatedAt time.Time)

SetUpdatedAt sets the updated at

func (*RoomUser) SetUserID

func (r *RoomUser) SetUserID(userID string)

SetUserID sets the user id

type RoomUserRole

type RoomUserRole string
const (
	RoomUserRoleAdmin  RoomUserRole = "admin"
	RoomUserRoleMember RoomUserRole = "member"
)

type RoomUserStatus

type RoomUserStatus string
const (
	RoomUserStatusActive RoomUserStatus = "active"
	RoomUserStatusLeft   RoomUserStatus = "left"
)

Jump to

Keyboard shortcuts

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