From 314db5f6c7380ab269c1f55f2b388387736bfbeb Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 18 Nov 2016 17:36:28 +0000 Subject: [PATCH] Fix #105 : Mention which label was added/removed --- .../go-neb/services/github/webhook/webhook.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/github.com/matrix-org/go-neb/services/github/webhook/webhook.go b/src/github.com/matrix-org/go-neb/services/github/webhook/webhook.go index b70614e..8d1b625 100644 --- a/src/github.com/matrix-org/go-neb/services/github/webhook/webhook.go +++ b/src/github.com/matrix-org/go-neb/services/github/webhook/webhook.go @@ -6,14 +6,15 @@ import ( "encoding/hex" "encoding/json" "fmt" - log "github.com/Sirupsen/logrus" - "github.com/google/go-github/github" - "github.com/matrix-org/go-neb/errors" - "github.com/matrix-org/go-neb/matrix" "html" "io/ioutil" "net/http" "strings" + + log "github.com/Sirupsen/logrus" + "github.com/google/go-github/github" + "github.com/matrix-org/go-neb/errors" + "github.com/matrix-org/go-neb/matrix" ) // OnReceiveRequest processes incoming github webhook requests and returns a @@ -148,11 +149,15 @@ func issueHTMLMessage(p github.IssuesEvent) string { if p.Issue.Assignee != nil && p.Issue.Assignee.Login != nil { actionTarget = fmt.Sprintf(" to %s", *p.Issue.Assignee.Login) } + action := html.EscapeString(*p.Action) + if p.Label != nil && (*p.Action == "labeled" || *p.Action == "unlabeled") { + action = *p.Action + " [" + html.EscapeString(*p.Label.Name) + "] to" + } return fmt.Sprintf( "[%s] %s %s issue #%d: %s [%s]%s - %s", html.EscapeString(*p.Repo.FullName), html.EscapeString(*p.Sender.Login), - html.EscapeString(*p.Action), + action, *p.Issue.Number, html.EscapeString(*p.Issue.Title), html.EscapeString(*p.Issue.State),