mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-09-18 23:02:31 +00:00
.github
bridge
gateway
hook
matterclient
matterhook
vendor
github.com
BurntSushi
GeertJohan
Sirupsen
alecthomas
bwmarrin
daaku
dgrijalva
facebookgo
go-telegram-bot-api
google
gorilla
jpillora
kardianos
labstack
matrix-org
mattermost
platform
einterfaces
model
gitlab
LICENSE.txt
access.go
analytics_row.go
audit.go
audits.go
authorization.go
authorize.go
channel.go
channel_count.go
channel_data.go
channel_list.go
channel_member.go
channel_search.go
channel_stats.go
channel_view.go
client.go
client4.go
cluster_info.go
cluster_stats.go
command.go
command_args.go
command_response.go
compliance.go
compliance_post.go
config.go
emoji.go
file.go
file_info.go
gitlab.go
incoming_webhook.go
initial_load.go
job.go
ldap.go
license.go
oauth.go
outgoing_webhook.go
password_recovery.go
post.go
post_list.go
preference.go
preferences.go
push_notification.go
push_response.go
reaction.go
saml.go
search_params.go
security_bulletin.go
session.go
slack_attachment.go
status.go
suggest_command.go
system.go
team.go
team_member.go
team_stats.go
user.go
user_autocomplete.go
user_search.go
utils.go
version.go
webrtc.go
websocket_client.go
websocket_message.go
websocket_request.go
vendor
mattn
mreiferson
mrexodia
nicksnyder
nlopes
pborman
peterhellberg
russross
satori
shurcooL
sorcix
sromku
technoweenie
thoj
tylerb
valyala
zfjagann
golang.org
gopkg.in
manifest
Dockerfile
LICENSE
README-0.6.md
README.md
changelog.md
matterbridge.go
matterbridge.toml.sample
matterbridge.toml.simple
migration.md
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"io"
|
|
)
|
|
|
|
const (
|
|
COMMAND_RESPONSE_TYPE_IN_CHANNEL = "in_channel"
|
|
COMMAND_RESPONSE_TYPE_EPHEMERAL = "ephemeral"
|
|
)
|
|
|
|
type CommandResponse struct {
|
|
ResponseType string `json:"response_type"`
|
|
Text string `json:"text"`
|
|
Username string `json:"username"`
|
|
IconURL string `json:"icon_url"`
|
|
GotoLocation string `json:"goto_location"`
|
|
Attachments []*SlackAttachment `json:"attachments"`
|
|
}
|
|
|
|
func (o *CommandResponse) ToJson() string {
|
|
b, err := json.Marshal(o)
|
|
if err != nil {
|
|
return ""
|
|
} else {
|
|
return string(b)
|
|
}
|
|
}
|
|
|
|
func CommandResponseFromJson(data io.Reader) *CommandResponse {
|
|
decoder := json.NewDecoder(data)
|
|
var o CommandResponse
|
|
|
|
if err := decoder.Decode(&o); err != nil {
|
|
return nil
|
|
}
|
|
|
|
// Ensure attachment fields are stored as strings
|
|
for _, attachment := range o.Attachments {
|
|
for _, field := range attachment.Fields {
|
|
if field.Value != nil {
|
|
field.Value = fmt.Sprintf("%v", field.Value)
|
|
}
|
|
}
|
|
}
|
|
|
|
return &o
|
|
}
|