Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/notifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,7 @@ type RocketchatConfig struct {
Title string `yaml:"title,omitempty" json:"title,omitempty"`
TitleLink string `yaml:"title_link,omitempty" json:"title_link,omitempty"`
Text string `yaml:"text,omitempty" json:"text,omitempty"`
PlainText string `yaml:"plain_text,omitempty" json:"plain_text,omitempty"`
Fields []*RocketchatAttachmentField `yaml:"fields,omitempty" json:"fields,omitempty"`
ShortFields bool `yaml:"short_fields" json:"short_fields,omitempty"`
Emoji string `yaml:"emoji,omitempty" json:"emoji,omitempty"`
Expand Down
15 changes: 9 additions & 6 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1360,12 +1360,15 @@ token_id_file: <filepath>


[ color: <tmpl_string | default '{{ if eq .Status "firing" }}red{{ else }}green{{ end }}' ]
[ emoji <tmpl_string | default = '{{ template "rocketchat.default.emoji" . }}'
[ icon_url <tmpl_string | default = '{{ template "rocketchat.default.iconurl" . }}'
[ text <tmpl_string | default = '{{ template "rocketchat.default.text" . }}'
[ title <tmpl_string | default = '{{ template "rocketchat.default.title" . }}'
[ titleLink <tmpl_string | default = '{{ template "rocketchat.default.titlelink" . }}'
[ text: <tmpl_string | default = '{{ template "rocketchat.default.text" . }}'
[ emoji: <tmpl_string | default = '{{ template "rocketchat.default.emoji" . }}' ]
[ icon_url: <tmpl_string | default = '{{ template "rocketchat.default.iconurl" . }}' ]
[ text: <tmpl_string | default = '{{ template "rocketchat.default.text" . }}' ]
[ title: <tmpl_string | default = '{{ template "rocketchat.default.title" . }}' ]
[ titleLink: <tmpl_string | default = '{{ template "rocketchat.default.titlelink" . }}' ]
[ text: <tmpl_string | default = '{{ template "rocketchat.default.text" . }}' ]
# rocketchat notifications do not contain attachment title, you could set this
# to {{ template "rocketchat.default.title" . }} to include title in push
[ plain_text: <tmpl_string> ]
fields:
[ <rocketchat_field_config> ... ]
[ image_url <tmpl_string> ]
Expand Down
8 changes: 4 additions & 4 deletions notify/rocketchat/rocketchat.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ type Notifier struct {
postJSONFunc func(ctx context.Context, client *http.Client, url string, body io.Reader) (*http.Response, error)
}

// PostMessage Payload for postmessage rest API
// PostMessage.Attachment Payload for postmessage rest API
//
// https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage/
// https://developer.rocket.chat/apidocs/post-message
type Attachment struct {
Title string `json:"title,omitempty"`
TitleLink string `json:"title_link,omitempty"`
Expand All @@ -62,11 +62,10 @@ type Attachment struct {

// PostMessage Payload for postmessage rest API
//
// https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage/
// https://developer.rocket.chat/apidocs/post-message
type PostMessage struct {
Channel string `json:"channel,omitempty"`
Text string `json:"text,omitempty"`
ParseUrls bool `json:"parseUrls,omitempty"`
Alias string `json:"alias,omitempty"`
Emoji string `json:"emoji,omitempty"`
Avatar string `json:"avatar,omitempty"`
Expand Down Expand Up @@ -205,6 +204,7 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
Channel: tmplText(n.conf.Channel),
Emoji: tmplText(n.conf.Emoji),
Avatar: tmplText(n.conf.IconURL),
Text: tmplText(n.conf.PlainText),
Attachments: []Attachment{*att},
}
if err != nil {
Expand Down