Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
33 lines
860 B
Go
33 lines
860 B
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/mattermost/mattermost/server/v8/channels/app/imaging"
|
|
)
|
|
|
|
func checkImageResolutionLimit(w, h int, maxRes int64) error {
|
|
// This casting is done to prevent overflow on 32 bit systems (not needed
|
|
// in 64 bits systems because images can't have more than 32 bits height or
|
|
// width)
|
|
imageRes := int64(w) * int64(h)
|
|
if imageRes > maxRes {
|
|
return fmt.Errorf("image resolution is too high: %d, max allowed is %d", imageRes, maxRes)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func checkImageLimits(imageData io.Reader, maxRes int64) error {
|
|
w, h, err := imaging.GetDimensions(imageData)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to get image dimensions: %w", err)
|
|
}
|
|
|
|
return checkImageResolutionLimit(w, h, maxRes)
|
|
}
|