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>
32 lines
802 B
Go
32 lines
802 B
Go
package command
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// PluginAPI is the plugin API interface required to manage slash commands.
|
|
type PluginAPI interface {
|
|
GetBundlePath() (string, error)
|
|
}
|
|
|
|
// GetIconData returns the base64 encoding of a icon for a given path.
|
|
// The data returned may be used for slash command autocomplete.
|
|
func GetIconData(api PluginAPI, iconPath string) (string, error) {
|
|
bundlePath, err := api.GetBundlePath()
|
|
if err != nil {
|
|
return "", errors.Wrap(err, "couldn't get bundle path")
|
|
}
|
|
|
|
icon, err := os.ReadFile(filepath.Join(bundlePath, iconPath))
|
|
if err != nil {
|
|
return "", errors.Wrap(err, "failed to open icon")
|
|
}
|
|
|
|
return fmt.Sprintf("data:image/svg+xml;base64,%s", base64.StdEncoding.EncodeToString(icon)), nil
|
|
}
|