Files
zeekayandHanzo Dev 05e7bfa24b call the product Hanzo Team, and paint it in one ink
Renames the product across user-facing text -- 1475 lines, i18n and the
defaultMessage strings that must match it -- while leaving the names that
are code rather than prose: upstream copyright, Go import paths, the
@mattermost npm scope, i18n keys, Go template fields, and legacy theme
identifiers like AuthorType.Mattermost and the 'Mattermost' key that maps
an old theme to a new one. The rule is a word boundary on identifier
characters; MattermostEntry is a symbol, "Mattermost" in a sentence is
the product.

The theme goes monochrome. Hanzo and Hanzo Dark are the two built-ins and
Hanzo is the default, with the CSS custom properties that carry brand
colour outside the theme object -- sidebar, buttons, links, titles --
moved to black. Status colours stay: online, away, do-not-disturb and
error encode state, not brand, and flattening them to grey would cost
meaning to buy consistency.

The sign-in header drops the TEAM EDITION badge. It advertised which
licence tier you were on, and there are no tiers here. Booting without a
licence is now logged at debug rather than warned about, because it is
this server's normal condition rather than a fault.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-13 22:28:09 -07:00

107 lines
2.7 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package plugin
import (
"context"
"github.com/hashicorp/go-plugin"
)
const (
InternalKeyPrefix = "mmi_"
BotUserKey = InternalKeyPrefix + "botid"
)
// WithTestContext provides a context typically used to terminate a plugin from a unit test.
func WithTestContext(ctx context.Context) func(*plugin.ServeConfig) error {
return func(config *plugin.ServeConfig) error {
if config.Test == nil {
config.Test = &plugin.ServeTestConfig{}
}
config.Test.Context = ctx
return nil
}
}
// WithTestReattachConfigCh configures the channel to receive the ReattachConfig used to reattach
// an externally launched plugin instance with the Hanzo Team server.
func WithTestReattachConfigCh(reattachConfigCh chan<- *plugin.ReattachConfig) func(*plugin.ServeConfig) error {
return func(config *plugin.ServeConfig) error {
if config.Test == nil {
config.Test = &plugin.ServeTestConfig{}
}
config.Test.ReattachConfigCh = reattachConfigCh
return nil
}
}
// WithTestCloseCh provides a channel that signals when the plugin exits.
func WithTestCloseCh(closeCh chan<- struct{}) func(*plugin.ServeConfig) error {
return func(config *plugin.ServeConfig) error {
if config.Test == nil {
config.Test = &plugin.ServeTestConfig{}
}
config.Test.CloseCh = closeCh
return nil
}
}
// Starts the serving of a Hanzo Team plugin over net/rpc. gRPC is not supported.
//
// Call this when your plugin is ready to start. Options allow configuring plugins for testing
// scenarios.
func ClientMain(pluginImplementation any, opts ...func(config *plugin.ServeConfig) error) {
impl, ok := pluginImplementation.(interface {
SetAPI(api API)
SetDriver(driver Driver)
})
if !ok {
panic("Plugin implementation given must embed plugin.MattermostPlugin")
}
impl.SetAPI(nil)
impl.SetDriver(nil)
pluginMap := map[string]plugin.Plugin{
"hooks": &hooksPlugin{hooks: pluginImplementation},
}
serveConfig := &plugin.ServeConfig{
HandshakeConfig: handshake,
Plugins: pluginMap,
}
for _, opt := range opts {
err := opt(serveConfig)
if err != nil {
panic("failed to start serving plugin: " + err.Error())
}
}
plugin.Serve(serveConfig)
}
type MattermostPlugin struct {
// API exposes the plugin api, and becomes available just prior to the OnActive hook.
API API
Driver Driver
}
// SetAPI persists the given API interface to the plugin. It is invoked just prior to the
// OnActivate hook, exposing the API for use by the plugin.
func (p *MattermostPlugin) SetAPI(api API) {
p.API = api
}
// SetDriver sets the RPC client implementation to talk with the server.
func (p *MattermostPlugin) SetDriver(driver Driver) {
p.Driver = driver
}