Parse attachments only if theyre exist and message.Text is empty.

This commit is contained in:
Stanislav Nikitin 2017-09-19 01:08:24 +05:00
parent fcdd414573
commit 1cd99829e8

View File

@ -300,15 +300,24 @@ func (gp GitlabParser) parseTagPush(message slackmessage.SlackMessage) map[strin
return data return data
} }
func (gp GitlabParser) parseAttachments(message slackmessage.SlackMessage) map[string]string {
c.Log.Debugln("Parsing attachments...")
var data map[string]string
if strings.Contains(message.Attachments[0].Text, "Pipeline") && strings.Contains(message.Attachments[0].Text, "of branch") {
data = gp.parsePipelineMessage(message)
}
return data
}
func (gp GitlabParser) ParseMessage(message slackmessage.SlackMessage) map[string]string { func (gp GitlabParser) ParseMessage(message slackmessage.SlackMessage) map[string]string {
c.Log.Debugln("Parsing Gitlab message...") c.Log.Debugln("Parsing Gitlab message...")
var data map[string]string var data map[string]string
if len(message.Attachments) > 0 { if len(message.Attachments) > 0 && message.Text == "" {
if strings.Contains(message.Attachments[0].Text, "Pipeline") && strings.Contains(message.Attachments[0].Text, "of branch") { return gp.parseAttachments(message)
data = gp.parsePipelineMessage(message)
}
} }
if strings.Contains(message.Text, "pushed to") { if strings.Contains(message.Text, "pushed to") {