mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-24 13:43:12 +02:00
4b0fb92fba
- provides support for compiling Boards directly into the Mattermost suite server - a ServicesAPI interface replaces the PluginAPI to allow for implementations coming from pluginAPI and suite server. - a new product package provides a place to register Boards as a suite product and handles life-cycle events - a new boards package replaces much of the mattermost-plugin logic, allowing this to be shared between plugin and product - Boards now uses module workspaces; run make setup-go-work
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package webhook
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"io/ioutil"
|
|
"net/http"
|
|
|
|
"github.com/mattermost/focalboard/server/model"
|
|
"github.com/mattermost/focalboard/server/services/config"
|
|
|
|
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
|
)
|
|
|
|
// NotifyUpdate calls webhooks.
|
|
func (wh *Client) NotifyUpdate(block model.Block) {
|
|
if len(wh.config.WebhookUpdate) < 1 {
|
|
return
|
|
}
|
|
|
|
json, err := json.Marshal(block)
|
|
if err != nil {
|
|
wh.logger.Fatal("NotifyUpdate: json.Marshal", mlog.Err(err))
|
|
}
|
|
for _, url := range wh.config.WebhookUpdate {
|
|
resp, _ := http.Post(url, "application/json", bytes.NewBuffer(json)) //nolint:gosec
|
|
_, _ = ioutil.ReadAll(resp.Body)
|
|
resp.Body.Close()
|
|
|
|
wh.logger.Debug("webhook.NotifyUpdate", mlog.String("url", url))
|
|
}
|
|
}
|
|
|
|
// Client is a webhook client.
|
|
type Client struct {
|
|
config *config.Configuration
|
|
logger mlog.LoggerIFace
|
|
}
|
|
|
|
// NewClient creates a new Client.
|
|
func NewClient(config *config.Configuration, logger mlog.LoggerIFace) *Client {
|
|
return &Client{
|
|
config: config,
|
|
logger: logger,
|
|
}
|
|
}
|