Initial commit from mattermost-plugin-starter-template

This commit is contained in:
Felipe M 2025-07-30 13:12:52 +02:00
commit acbc69f7eb
No known key found for this signature in database
GPG key ID: 52E5D65FCF99808A
57 changed files with 27772 additions and 0 deletions

View file

@ -0,0 +1,29 @@
package kvstore
import (
"github.com/mattermost/mattermost/server/public/pluginapi"
"github.com/pkg/errors"
)
// We expose our calls to the KVStore pluginapi methods through this interface for testability and stability.
// This allows us to better control which values are stored with which keys.
type Client struct {
client *pluginapi.Client
}
func NewKVStore(client *pluginapi.Client) KVStore {
return Client{
client: client,
}
}
// Sample method to get a key-value pair in the KV store
func (kv Client) GetTemplateData(userID string) (string, error) {
var templateData string
err := kv.client.KV.Get("template_key-"+userID, &templateData)
if err != nil {
return "", errors.Wrap(err, "failed to get template data")
}
return templateData, nil
}