-
Notifications
You must be signed in to change notification settings - Fork 42
/
formatting.go
53 lines (45 loc) · 1.09 KB
/
formatting.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package jira
import (
"fmt"
"strings"
"github.com/andygrunwald/go-jira"
"github.com/innogames/slack-bot/bot/config"
)
// replace Jira markdown to valid slack message
var markdownReplacer = strings.NewReplacer(
"{code}", "```",
"{quote}", "```",
"h1. ", "",
"h2. ", "",
"h3. ", "",
)
// todo map all icons in config (Priority.Name.Blocker = :jira_blocker: ...
// todo move to default map
func idToIcon(priority *jira.Priority) string {
if priority == nil {
return ":question:"
}
switch priority.Name {
case "Blocker":
return ":jira_blocker:"
case "Critical":
return ":jira_critical:"
case "Major":
return ":jira_major:"
case "Medium":
return ":jira_medium:"
case "Minor":
return ":jira_minor:"
default:
return ":white_circle:"
}
}
func convertMarkdown(content string) string {
return markdownReplacer.Replace(content)
}
func getFormattedURL(cfg *config.Jira, issue jira.Issue) string {
return fmt.Sprintf("<%s|%s>", getTicketURL(cfg, issue), issue.Key)
}
func getTicketURL(cfg *config.Jira, issue jira.Issue) string {
return fmt.Sprintf("%sbrowse/%s", cfg.Host, issue.Key)
}