Files
zeekay 8feb24ea1f One name for this fork, and it is ours
The server module named github.com/hanzoai/team/server/v8 — a path that
resolves to the retired workspace's repository, not this one — while
server/public still published github.com/mattermost/mattermost/server/public.
Both are github.com/hanzoteam/server/... now, which is where this code
actually lives.

That second half is what made the binary unbootable. Upstream's public path
stayed claimed by upstream, mattermost-plugin-ai imported it, and the build
linked public/model twice; public/plugin's gob.Register then ran twice under
one name and panicked at init, before main. Reverting the rename traded the
brand for a working binary. Rebranding the plugin alongside it needs no such
trade: the agents fork is github.com/hanzoteam/agents/v2 against our public
module, so no module named mattermost/mattermost is in the graph at all.

Measured: `go list -deps ./cmd/mattermost` names exactly one public/model, and
it is ours.
2026-08-28 23:35:36 -07:00

84 lines
2.4 KiB
Go

package pluginapi
import (
"github.com/Masterminds/semver/v3"
"github.com/hanzoteam/server/server/public/plugin"
"github.com/pkg/errors"
)
// Client is a streamlined wrapper over the mattermost plugin API.
type Client struct {
api plugin.API
Audit AuditService
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,
Audit: AuditService{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.LessThan(requiredVersion) {
return errors.Errorf("incompatible server version for plugin, minimum required version: %s, current version: %s", required, serverVersion)
}
return nil
}