grim/youtrack-import

d591598025d7
Replace mentions with the youtrack login name. Fixes YI-7
package bitbucket
import (
"regexp"
"strings"
"hg.sr.ht/~grim/youtrack-import/youtrack"
)
var (
mentionRegex = regexp.MustCompile(`@\{(.+?)\}`)
)
func replaceMentions(m map[string]*youtrack.User, message string) string {
output := message
matches := mentionRegex.FindAllStringSubmatch(message, -1)
for _, match := range matches {
old := match[0]
id := match[1]
if user, found := m[id]; found {
output = strings.Replace(output, old, "@"+user.Login, 1)
}
}
return output
}
func replaceKeywords(m map[string]*youtrack.User, message string) string {
output := message
output = replaceMentions(m, output)
return output
}