Initial commit from mattermost-plugin-starter-template
This commit is contained in:
commit
acbc69f7eb
57 changed files with 27772 additions and 0 deletions
29
server/store/kvstore/startertemplate.go
Normal file
29
server/store/kvstore/startertemplate.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue