Documentation ¶
Index ¶
- Variables
- type AttachmentLoader
- type ChatStoreDatabase
- func (s *ChatStoreDatabase) DeleteMessage(ctxCtx context.Context, id snowflake.ID) (*Message, error)
- func (s *ChatStoreDatabase) GetUserNickname(ctx context.Context, user auth.User) *string
- func (s *ChatStoreDatabase) LoadAttachment(ctx context.Context, attachmentString string) (MessageAttachmentView, error)
- func (s *ChatStoreDatabase) LoadMessage(ctxCtx context.Context, id snowflake.ID) (*Message, error)
- func (s *ChatStoreDatabase) LoadMessagesBetween(ctxCtx context.Context, includeShadowbanned auth.User, since, until time.Time) ([]*Message, error)
- func (s *ChatStoreDatabase) LoadNumLatestMessages(ctxCtx context.Context, includeShadowbanned auth.User, num int) ([]*Message, error)
- func (s *ChatStoreDatabase) LoadNumLatestMessagesFromUser(ctxCtx context.Context, user auth.User, num int) ([]*Message, error)
- func (s *ChatStoreDatabase) SetAttachmentLoaderForType(attachmentType string, attachmentLoader AttachmentLoader)
- func (s *ChatStoreDatabase) SetUserNickname(ctxCtx context.Context, user auth.User, nickname *string) error
- func (s *ChatStoreDatabase) StoreMessage(ctxCtx context.Context, m *Message) (*string, error)
- type EmoteCache
- type Message
- type MessageAttachmentStorage
- type MessageAttachmentStorageWithCost
- type MessageAttachmentView
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrChatMessageNotFound = errors.New("chat message not found")
ErrChatMessageNotFound is returned by a ChatStore when LoadMessage or DeleteMessage does not find the given message
Functions ¶
This section is empty.
Types ¶
type AttachmentLoader ¶
type AttachmentLoader func(context.Context, string) (MessageAttachmentView, error)
AttachmentLoader transforms a DB-serialized attachment storage model into the respective view model
type ChatStoreDatabase ¶
type ChatStoreDatabase struct {
// contains filtered or unexported fields
}
ChatStoreDatabase stores messages in the database
func NewStoreDatabase ¶
func NewStoreDatabase(log *log.Logger, nicknameCache usercache.UserCache) *ChatStoreDatabase
NewStoreDatabase initializes and returns a new ChatStoreDatabase
func (*ChatStoreDatabase) DeleteMessage ¶
func (*ChatStoreDatabase) GetUserNickname ¶
func (*ChatStoreDatabase) LoadAttachment ¶
func (s *ChatStoreDatabase) LoadAttachment(ctx context.Context, attachmentString string) (MessageAttachmentView, error)
func (*ChatStoreDatabase) LoadMessage ¶
func (*ChatStoreDatabase) LoadMessagesBetween ¶
func (*ChatStoreDatabase) LoadNumLatestMessages ¶
func (*ChatStoreDatabase) LoadNumLatestMessagesFromUser ¶
func (*ChatStoreDatabase) SetAttachmentLoaderForType ¶
func (s *ChatStoreDatabase) SetAttachmentLoaderForType(attachmentType string, attachmentLoader AttachmentLoader)
func (*ChatStoreDatabase) SetUserNickname ¶
func (*ChatStoreDatabase) StoreMessage ¶
type EmoteCache ¶
type EmoteCache struct {
// contains filtered or unexported fields
}
EmoteCache caches chat emote information
func (*EmoteCache) ChatEmotes ¶
type Message ¶
type Message struct { ID snowflake.ID CreatedAt time.Time Author auth.User Content string Reference *Message // may be nil Shadowbanned bool Attachments []MessageAttachmentStorage AttachmentsView []MessageAttachmentView }
Message represents a single chat message
func (*Message) SerializeForAPI ¶
func (m *Message) SerializeForAPI(ctx context.Context, userSerializer auth.APIUserSerializer) *proto.ChatMessage
type MessageAttachmentStorage ¶
type MessageAttachmentStorage interface { AttachmentType() string SerializeForDatabase(ctx context.Context) string }
MessageAttachmentStorage represents the submission and storage model for an attachment
type MessageAttachmentStorageWithCost ¶
type MessageAttachmentStorageWithCost interface { MessageAttachmentStorage PointsCost() int PointsTxType() types.PointsTxType }
MessageAttachmentStorage represents the submission and storage model for an attachment that has a points cost
type MessageAttachmentView ¶
type MessageAttachmentView interface { SerializeForAPI(ctx context.Context) *proto.ChatMessageAttachment SerializeForModLog(ctx context.Context) string SerializeForJS(ctx context.Context, vm *goja.Runtime) map[string]interface{} }
MessageAttachmentView represents the view model for an attachment
type Store ¶
type Store interface { StoreMessage(context.Context, *Message) (*string, error) DeleteMessage(context.Context, snowflake.ID) (*Message, error) LoadMessagesBetween(context.Context, auth.User, time.Time, time.Time) ([]*Message, error) LoadNumLatestMessages(context.Context, auth.User, int) ([]*Message, error) LoadNumLatestMessagesFromUser(context.Context, auth.User, int) ([]*Message, error) LoadMessage(context.Context, snowflake.ID) (*Message, error) SetUserNickname(context.Context, auth.User, *string) error GetUserNickname(context.Context, auth.User) *string SetAttachmentLoaderForType(attachmentType string, attachmentLoader AttachmentLoader) LoadAttachment(ctx context.Context, attachmentString string) (MessageAttachmentView, error) }
Store can save and load chat messages