Documentation ¶
Index ¶
- func IsValidMessageType(messageType string) bool
- type Message
- func (m *Message) GetContent() string
- func (m *Message) GetCreatedAt() time.Time
- func (m *Message) GetID() string
- func (m *Message) GetMessageType() MessageType
- func (m *Message) GetRoomID() string
- func (m *Message) GetSenderID() string
- func (m *Message) GetUpdatedAt() *time.Time
- func (m *Message) SetContent(content string)
- func (m *Message) SetCreatedAt(createdAt time.Time)
- func (m *Message) SetID(id string)
- func (m *Message) SetMessageType(messageType MessageType)
- func (m *Message) SetRoomID(roomID string)
- func (m *Message) SetSenderID(senderID string)
- func (m *Message) SetUpdatedAt(updatedAt *time.Time)
- type MessageType
- type Room
- func (r *Room) AddRoomUser(user RoomUser)
- func (r *Room) CheckRoomUserExists(userID string) bool
- func (r *Room) GetCreatedAt() time.Time
- func (r *Room) GetID() string
- func (r *Room) GetLastMessageAt() *time.Time
- func (r *Room) GetLastMessageID() string
- func (r *Room) GetRoomConfig() RoomConfig
- func (r *Room) GetRoomMeta() RoomMeta
- func (r *Room) GetRoomUsers() []RoomUser
- func (r *Room) GetUpdatedAt() *time.Time
- func (r *Room) RemoveRoomUser(userID string)
- func (r *Room) SetCreatedAt(t time.Time)
- func (r *Room) SetID(id string)
- func (r *Room) SetLastMessage(id string)
- func (r *Room) SetRoomConfig(config RoomConfig)
- func (r *Room) SetRoomMeta(meta RoomMeta)
- func (r *Room) SetRoomUsers(users []RoomUser)
- func (r *Room) SetUpdatedAt(t *time.Time)
- type RoomConfig
- type RoomMeta
- type RoomType
- type RoomUser
- type RoomUserRole
- type RoomUserStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidMessageType ¶
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 ¶
GetContent returns the content of the message
func (*Message) GetCreatedAt ¶
GetCreatedAt returns the created at timestamp of the message
func (*Message) GetMessageType ¶
func (m *Message) GetMessageType() MessageType
GetMessageType returns the message type of the message
func (*Message) GetSenderID ¶
GetSenderID returns the sender id of the message
func (*Message) GetUpdatedAt ¶
GetUpdatedAt returns the updated at timestamp of the message
func (*Message) SetContent ¶
SetContent sets the content of the message
func (*Message) SetCreatedAt ¶
SetCreatedAt sets the created at timestamp of the message
func (*Message) SetMessageType ¶
func (m *Message) SetMessageType(messageType MessageType)
SetMessageType sets the message type of the message
func (*Message) SetSenderID ¶
SetSenderID sets the sender id of the message
func (*Message) SetUpdatedAt ¶
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 (*Room) AddRoomUser ¶
AddRoomUser adds a room user to the room entity
func (*Room) CheckRoomUserExists ¶
CheckRoomUserExists checks if a room user exists in the room entity
func (*Room) GetCreatedAt ¶
GetCreatedAt returns the created at timestamp of the room entity
func (*Room) GetLastMessageAt ¶
GetLastMessageAt returns the last message timestamp of the room entity
func (*Room) GetLastMessageID ¶
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 ¶
GetRoomMeta returns the room meta of the room entity
func (*Room) GetRoomUsers ¶
GetRoomUsers returns the room users of the room entity
func (*Room) GetUpdatedAt ¶
GetUpdatedAt returns the updated at timestamp of the room entity
func (*Room) RemoveRoomUser ¶
RemoveRoomUser removes a room user from the room entity
func (*Room) SetCreatedAt ¶
SetCreatedAt sets the created at timestamp for the room entity
func (*Room) SetLastMessage ¶
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 ¶
SetRoomMeta sets the room meta of the room entity
func (*Room) SetRoomUsers ¶
SetRoomUsers sets the room users of the room entity
func (*Room) SetUpdatedAt ¶
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 ¶
func NewRoomMeta ¶
NewRoomMeta creates a new RoomMeta
func (*RoomMeta) SetDescription ¶
SetDescription sets the description of the entity
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 ¶
SetCreatedAt sets the created at
func (*RoomUser) SetIsMuted ¶
SetIsMuted sets the is muted
func (*RoomUser) SetStatus ¶
func (r *RoomUser) SetStatus(status RoomUserStatus)
SetStatus sets the status
func (*RoomUser) SetUpdatedAt ¶
SetUpdatedAt sets the updated at
type RoomUserRole ¶
type RoomUserRole string
const ( RoomUserRoleAdmin RoomUserRole = "admin" RoomUserRoleMember RoomUserRole = "member" )
type RoomUserStatus ¶
type RoomUserStatus string
const ( RoomUserStatusActive RoomUserStatus = "active" RoomUserStatusLeft RoomUserStatus = "left" )