chat

package
v0.0.0-...-24ffa16 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unset           uint8 = iota
	Whisper         uint8 = iota
	PrivMsg         uint8 = iota
	ClearChat       uint8 = iota
	RoomState       uint8 = iota
	UserNotice      uint8 = iota
	UserState       uint8 = iota
	Notice          uint8 = iota
	Join            uint8 = iota
	Part            uint8 = iota
	Reconnect       uint8 = iota
	Names           uint8 = iota
	Ping            uint8 = iota
	Pong            uint8 = iota
	ClearMsg        uint8 = iota
	GlobalUserState uint8 = iota
)

Variables

This section is empty.

Functions

func FilterMessageStream

func FilterMessageStream(ctx context.Context, messageStream <-chan *Message, allowedTypes []uint8) <-chan *Message

func SaveMessageStream

func SaveMessageStream(ctx context.Context, messagesStream <-chan *Message, repository Repository)

Types

type Channel

type Channel struct {
	ID   uuid.UUID `ch:"id"`
	Name string    `ch:"name"`
	Time time.Time `ch:"timestamp"`
}

type GetMessageStream

type GetMessageStream func(ctx context.Context, messageTypes []uint8) (<-chan *Message, error)

type Message

type Message struct {
	Username    string    `ch:"username"`
	ChannelName string    `ch:"channel"`
	Message     string    `ch:"message"`
	MessageType uint8     `ch:"message_type"`
	Time        time.Time `ch:"timestamp"`
}

type Repository

type Repository interface {
	SaveMessage(ctx context.Context, message *Message) error
	GetMessages(ctx context.Context, channel, username string, limit, offset int) ([]*Message, error)
	GetChannels(ctx context.Context) ([]*Channel, error)
	GetChannel(ctx context.Context, uuid uuid.UUID) (*Channel, error)
	SaveChannel(ctx context.Context, channel *Channel) error
	DeleteChannel(ctx context.Context, channel *Channel) error
}

Jump to

Keyboard shortcuts

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