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 ¶
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 ¶
var ErrChannelDescriptionTooLong = apperr.Invalid("channel: description too long")
ErrChannelDescriptionTooLong guards the description field.
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).
var ErrChannelNameTooLong = apperr.Invalid("channel: name too long")
ErrChannelNameTooLong is returned when the name is over MaxChannelNameLen.
var ErrMessageTooLong = apperr.Invalid("message: body exceeds maximum length")
ErrMessageTooLong is returned by Send/Edit when the body exceeds MaxMessageBodyChars in codepoints.
var ErrTooManyAttachments = apperr.Invalid("message: too many attachments")
ErrTooManyAttachments is returned by Send/Edit when more attachment IDs are supplied than the cap allows.
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 ¶
ValidateAttachmentCount enforces the per-message attachment cap.
func ValidateChannelDescription ¶
ValidateChannelDescription caps the optional description by codepoints.
func ValidateChannelName ¶
ValidateChannelName enforces the slug-style pattern + length cap.
func ValidateMessageBody ¶
ValidateMessageBody enforces the codepoint cap. Empty bodies are allowed here — Send checks separately that body OR attachments exist.
Types ¶
This section is empty.