grafana/xmpp - try describing

This commit is contained in:
Martin/Geno 2019-02-13 19:51:23 +01:00
parent cfd2694693
commit bcfdc26bb9
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
3 changed files with 8 additions and 5 deletions

View File

@ -58,6 +58,7 @@ func init() {
logger = logger.WithFields(map[string]interface{}{
"url": request.RuleURL,
"msg": request.String(),
"image": request.ImageURL,
})
ruleURL, err := url.Parse(request.RuleURL)
@ -72,10 +73,11 @@ func init() {
if ruleURL.Hostname() != hook.URL {
continue
}
runtime.Notify(client, hook, request.String())
if request.ImageURL != "" {
logger = logger.WithField("image", request.ImageURL)
runtime.NotifyImage(client, hook, request.ImageURL)
runtime.NotifyImage(client, hook, request.ImageURL, request.String())
}else{
}
logger.Infof("run hook")
ok = true

View File

@ -87,9 +87,9 @@ func main() {
}
}
log.Infof("started hock2xmpp with %s", client.JID())
notify("startup of hock2xmpp")
log.Infof("started hock2xmpp with %s", client.JID())
// Wait for system signal
sigs := make(chan os.Signal, 1)

View File

@ -25,13 +25,14 @@ func Start(client *xmpp.Client) {
}
}
}
func NotifyImage(client *xmpp.Client, hook Hook, url string) {
func NotifyImage(client *xmpp.Client, hook Hook, url string, desc string) {
msg := fmt.Sprintf(`<message to='%%s' type='%%s'>
<body>%s</body>
<x xmlns='jabber:x:oob'>
<url>%s</url>
<desc>%s</desc>
</x>
</message>`, url, url)
</message>`, url, url, desc)
for _, muc := range hook.NotifyMuc {
client.SendOrg(fmt.Sprintf(msg, muc, "groupchat"))