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

85 lines
1.8 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package main
import (
"bytes"
"fmt"
"github.com/hanzoteam/server/server/public/model"
"github.com/hanzoteam/server/server/public/plugin"
"github.com/hanzoteam/server/server/v8/channels/app/plugin_api_tests"
)
type MyPlugin struct {
plugin.MattermostPlugin
configuration plugin_api_tests.BasicConfig
}
func (p *MyPlugin) OnConfigurationChange() error {
if err := p.API.LoadPluginConfiguration(&p.configuration); err != nil {
return err
}
return nil
}
func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model.Post, string) {
data := []byte("some data")
appErr := p.API.KVSet("some_key", data)
if appErr != nil {
return nil, appErr.Error()
}
rData, appErr := p.API.KVGet("some_key")
if appErr != nil {
return nil, appErr.Error()
}
if !bytes.Equal(data, rData) {
return nil, fmt.Sprintf("Data not equal, expected: %s, got: %s", string(data), string(rData))
}
data = []byte("some other data")
var longKey string
for range model.KeyValueKeyMaxRunes {
longKey += "k"
}
appErr = p.API.KVSet(longKey, data)
if appErr != nil {
return nil, appErr.Error()
}
rData, appErr = p.API.KVGet(longKey)
if appErr != nil {
return nil, appErr.Error()
}
if !bytes.Equal(data, rData) {
return nil, fmt.Sprintf("Data not equal, expected: %s, got: %s", string(data), string(rData))
}
longKey += "extra"
appErr = p.API.KVSet(longKey, data)
if appErr == nil {
return nil, "Should have gotten an error for a to long key"
}
rData, appErr = p.API.KVGet(longKey)
if appErr != nil {
return nil, "Should have gotten an error for a to long key"
}
if rData != nil {
return nil, "Returned data should have been nil"
}
return nil, "OK"
}
func main() {
plugin.ClientMain(&MyPlugin{})
}