mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-21 13:38:56 +02:00
c8e729b6fe
* refactor: updated dependency for focalboard server * chore: more dependency fixes * refactor: removed the unless code * refactor: added ctx for login and removed unnessary code * refactor: bump up go version * refactor: removed the commented code * chore: upgraded golinter version * fix: linter issue * refactor: removed feature flg fix golinter * refactor: removed feature flag from code * revert: statistic and it's function * refactor: removed ProductLimit related code * refactor: removed isWithinViewsLimit implementation * refactor: moved function GetUsedCardsCount to statistics.go from cloud.go * refactor: removed insight code board * refactor: removed limit dialog * refactor: updated dependencies for linux * chore: golinter fix * chore: updated helper test function to use newLogger * fix: go test * refactor: db ping attempts from config * revert: feature in action * revert: feature flag in action * revert: boardsEditor setting --------- Co-authored-by: Rajat Dabade <rajat@Rajats-MacBook-Pro.local>
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package webhook
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"io"
|
|
"net/http"
|
|
|
|
"github.com/mattermost/focalboard/server/model"
|
|
"github.com/mattermost/focalboard/server/services/config"
|
|
|
|
"github.com/mattermost/mattermost/server/public/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
|
|
_, _ = io.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,
|
|
}
|
|
}
|