mattermost-community-enterp.../public/pluginapi/client.go
Claude ec1f89217a Merge: Complete Mattermost Server with Community Enterprise
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>
2025-12-17 23:59:07 +09:00

82 lines
2.3 KiB
Go

package pluginapi
import (
"github.com/blang/semver/v4"
"github.com/mattermost/mattermost/server/public/plugin"
"github.com/pkg/errors"
)
// Client is a streamlined wrapper over the mattermost plugin API.
type Client struct {
api plugin.API
Bot BotService
Channel ChannelService
Cluster ClusterService
Configuration ConfigurationService
SlashCommand SlashCommandService
OAuth OAuthService
Emoji EmojiService
File FileService
Frontend FrontendService
Group GroupService
KV KVService
Log LogService
Mail MailService
Plugin PluginService
Post PostService
Property PropertyService
Session SessionService
Store *StoreService
System SystemService
Team TeamService
User UserService
}
// NewClient creates a new instance of Client.
//
// This client must only be created once per plugin to
// prevent reacquiring of resources.
func NewClient(api plugin.API, driver plugin.Driver) *Client {
return &Client{
api: api,
Bot: BotService{api: api},
Channel: ChannelService{api: api},
Cluster: ClusterService{api: api},
Configuration: ConfigurationService{api: api},
SlashCommand: SlashCommandService{api: api},
OAuth: OAuthService{api: api},
Emoji: EmojiService{api: api},
File: FileService{api: api},
Frontend: FrontendService{api: api},
Group: GroupService{api: api},
KV: KVService{api: api},
Log: LogService{api: api},
Mail: MailService{api: api},
Plugin: PluginService{api: api},
Post: PostService{api: api},
Property: PropertyService{api: api},
Session: SessionService{api: api},
Store: &StoreService{
api: api,
driver: driver,
},
System: SystemService{api: api},
Team: TeamService{api: api},
User: UserService{api: api},
}
}
func ensureServerVersion(api plugin.API, required string) error {
serverVersion := api.GetServerVersion()
currentVersion := semver.MustParse(serverVersion)
requiredVersion := semver.MustParse(required)
if currentVersion.LT(requiredVersion) {
return errors.Errorf("incompatible server version for plugin, minimum required version: %s, current version: %s", required, serverVersion)
}
return nil
}