limits

package
v0.0.122 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: GPL-3.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package limits holds the hard input ceilings and their validators, shared by the service layer and the history importer so both enforce identical rules.

Index

Constants

View Source
const (
	// MaxMessageBodyChars caps the message body in user-perceived
	// characters (Unicode codepoints). UTF-8 is variable-width, so a
	// byte cap would penalise non-Latin scripts; a codepoint cap is
	// fair and predictable for the user. 16383 is the Mattermost post
	// ceiling; we round to 16384 so incoming-webhook payloads at that
	// limit are accepted rather than rejected.
	MaxMessageBodyChars = 16384

	// MaxAttachmentsPerMessage caps how many attachments can be bound
	// to a single message at send time. Editing follows the same cap.
	MaxAttachmentsPerMessage = 10

	// MaxMessageListLimit is the largest page/window size accepted by
	// message-list handlers before any store query or slice allocation.
	MaxMessageListLimit = 100

	// MaxChannelNameLen / MaxChannelDescriptionLen / MaxDistinctReactions
	// guard the rest of the message-adjacent surface against abuse.
	MaxChannelNameLen        = 32
	MaxChannelDescriptionLen = 1000
	MaxDistinctReactions     = 16

	// MaxDisplayNameChars caps a user's display name in codepoints.
	MaxDisplayNameChars = 80

	// MaxUserGroupNameChars / MaxUserGroupDescriptionChars cap a user
	// group's name and description in codepoints.
	MaxUserGroupNameChars        = 80
	MaxUserGroupDescriptionChars = 250
)

Hard ceilings the API enforces. Mirrored on the frontend in src/lib/limits.ts — keep them in sync.

Variables

View Source
var ErrChannelDescriptionTooLong = apperr.Invalid("channel: description too long")

ErrChannelDescriptionTooLong guards the description field.

View Source
var ErrChannelNameInvalid = apperr.Invalid("channel: name must be lowercase letters, digits, and hyphens")

ErrChannelNameInvalid is returned when a channel name doesn't fit the slug pattern (lowercase letters, digits, hyphen — no special chars, no leading/trailing/repeated hyphens).

View Source
var ErrChannelNameTooLong = apperr.Invalid("channel: name too long")

ErrChannelNameTooLong is returned when the name is over MaxChannelNameLen.

View Source
var ErrMessageTooLong = apperr.Invalid("message: body exceeds maximum length")

ErrMessageTooLong is returned by Send/Edit when the body exceeds MaxMessageBodyChars in codepoints.

View Source
var ErrTooManyAttachments = apperr.Invalid("message: too many attachments")

ErrTooManyAttachments is returned by Send/Edit when more attachment IDs are supplied than the cap allows.

View Source
var ErrTooManyReactions = apperr.Invalid("message: too many distinct reactions")

ErrTooManyReactions is returned by ToggleReaction when adding the emoji would push the distinct-reactions count past the cap.

Functions

func ValidateAttachmentCount

func ValidateAttachmentCount(n int) error

ValidateAttachmentCount enforces the per-message attachment cap.

func ValidateChannelDescription

func ValidateChannelDescription(desc string) error

ValidateChannelDescription caps the optional description by codepoints.

func ValidateChannelName

func ValidateChannelName(name string) error

ValidateChannelName enforces the slug-style pattern + length cap.

func ValidateMessageBody

func ValidateMessageBody(body string) error

ValidateMessageBody enforces the codepoint cap. Empty bodies are allowed here — Send checks separately that body OR attachments exist.

Types

This section is empty.

Jump to

Keyboard shortcuts

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