mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-05 03:34:03 +00:00
Update vendor (github.com/mattermost)
This commit is contained in:
23
vendor/github.com/mattermost/platform/model/command_response.go
generated
vendored
23
vendor/github.com/mattermost/platform/model/command_response.go
generated
vendored
@ -6,6 +6,8 @@ package model
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -18,6 +20,8 @@ type CommandResponse struct {
|
||||
Text string `json:"text"`
|
||||
Username string `json:"username"`
|
||||
IconURL string `json:"icon_url"`
|
||||
Type string `json:"type"`
|
||||
Props StringInterface `json:"props"`
|
||||
GotoLocation string `json:"goto_location"`
|
||||
Attachments []*SlackAttachment `json:"attachments"`
|
||||
}
|
||||
@ -31,6 +35,22 @@ func (o *CommandResponse) ToJson() string {
|
||||
}
|
||||
}
|
||||
|
||||
func CommandResponseFromHTTPBody(contentType string, body io.Reader) *CommandResponse {
|
||||
if strings.TrimSpace(strings.Split(contentType, ";")[0]) == "application/json" {
|
||||
return CommandResponseFromJson(body)
|
||||
}
|
||||
if b, err := ioutil.ReadAll(body); err == nil {
|
||||
return CommandResponseFromPlainText(string(b))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CommandResponseFromPlainText(text string) *CommandResponse {
|
||||
return &CommandResponse{
|
||||
Text: text,
|
||||
}
|
||||
}
|
||||
|
||||
func CommandResponseFromJson(data io.Reader) *CommandResponse {
|
||||
decoder := json.NewDecoder(data)
|
||||
var o CommandResponse
|
||||
@ -39,8 +59,7 @@ func CommandResponseFromJson(data io.Reader) *CommandResponse {
|
||||
return nil
|
||||
}
|
||||
|
||||
o.Text = ExpandAnnouncement(o.Text)
|
||||
o.Attachments = ProcessSlackAttachments(o.Attachments)
|
||||
o.Attachments = StringifySlackFieldValue(o.Attachments)
|
||||
|
||||
return &o
|
||||
}
|
||||
|
Reference in New Issue
Block a user