message

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrUnableToGetUserToken         = "unable to get user token"
	ErrUnableToParseBody            = "unable to parse body"
	ErrPermissionsRequired          = "permissions required"
	ErrUnableToCreateAttachment     = "unable to create attachment"
	ErrUnableToCreateUploadURL      = "unable to create upload url"
	ErrIncorrectChannelID           = "incorrect channel ID"
	ErrIncorrectMessageID           = "incorrect message ID"
	ErrFileIsTooBig                 = "file is too big"
	ErrUnableToSendMessage          = "unable to send message"
	ErrUnableToUpdateMessage        = "unable to update message"
	ErrUnableToGetUser              = "unable to get user"
	ErrUnableToGetGuild             = "unable to get guild"
	ErrUnableToGetUserDiscriminator = "unable to get discriminator"
	ErrUnableToGetAttachements      = "unable to get attachments"
	ErrUnableToSentToThisChannel    = "unable to send to this channel"
	ErrUnableToReadFromThisChannel  = "unable to read from this channel"
	ErrUnableToGetMessage           = "unable to get message"

	// Validation error messages
	ErrMessageContentRequired = "message content is required"
	ErrMessageContentTooLong  = "message content must be less than 2000 characters"
	ErrAttachmentIdInvalid    = "attachment ID must be positive"
	ErrMentionIdInvalid       = "mention ID must be positive"
	ErrFilenameRequired       = "filename is required"
	ErrFilenameTooLong        = "filename must be less than 255 characters"
	ErrFileSizeInvalid        = "file size must be positive"
	ErrFileSizeTooBig         = "file size must be less than 100MB"
	ErrDimensionsInvalid      = "width and height must be non-negative"
	ErrLimitInvalid           = "limit must be between 1 and 100"
	ErrFromIdInvalid          = "from ID must be positive"
	ErrDirectionInvalid       = "direction must be 'before' or 'after'"
)
View Source
const (
	DirectionBefore = Direction("before")
	DirectionAfter  = Direction("after")
)
View Source
const (
	DefaultLimit = int(50)
)
View Source
const (
	MaxBatchSize = 50 // Maximum messages to process at once
)

Performance optimization constants

Variables

This section is empty.

Functions

func GetAttachmentType

func GetAttachmentType(contentType string) string

func HasURL

func HasURL(text string) bool

HasURL returns true if the input string contains at least one URL.

func New

func New(dbcon *db.CQLCon, pg *pgdb.DB, storage *s3.Client, t mq.SendTransporter, imq *indexmq.IndexMQ, uploadLimit int64, log *slog.Logger) server.Entity

func UniqueAttachmentTypes

func UniqueAttachmentTypes(types []string) []string

Types

type Direction

type Direction string

type GetMessagesRequest

type GetMessagesRequest struct {
	From      *int64     `query:"from" json:"from" example:"2230469276416868352"`                   // ID of the message whe start to look from
	Limit     *int       `query:"limit" json:"limit" example:"30"`                                  // Number of messages to return.
	Direction *Direction `query:"direction" json:"direction" enums:"before,after" example:"before"` // Direction to look for messages
}

func (GetMessagesRequest) Validate

func (r GetMessagesRequest) Validate() error

type SendMessageRequest

type SendMessageRequest struct {
	Content     string  `json:"content" example:"Hello world!"`            // Message content
	Attachments []int64 `json:"attachments" example:"2230469276416868352"` // IDs of attached files
	Mentions    []int64 `json:"mentions" example:"2230469276416868352"`    // IDs of mentioned users
}

func (SendMessageRequest) Validate

func (r SendMessageRequest) Validate() error

type UpdateMessageRequest

type UpdateMessageRequest struct {
	Content string `json:"content" example:"Hello world!"` // Message content
}

func (UpdateMessageRequest) Validate

func (r UpdateMessageRequest) Validate() error

type UploadAttachmentRequest

type UploadAttachmentRequest struct {
	Filename string `json:"filename" example:"image.png"` // File name
	FileSize int64  `json:"file_size" example:"100000"`   // File size in bytes
	Width    int64  `json:"width" example:"800"`          // Image width in pixels
	Height   int64  `json:"height" example:"600"`         // Image height in pixels
}

func (UploadAttachmentRequest) Validate

func (r UploadAttachmentRequest) Validate() error

Jump to

Keyboard shortcuts

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