Esempio n. 1
0
func FormatStories(stories []Story) []robots.Attachment {
	atts := []robots.Attachment{}

	for _, s := range stories {
		a := robots.Attachment{}
		a.Color = "#7CD197"
		a.Fallback = fmt.Sprintf("%s - *%s* %s (%s)\n",
			strings.Title(s.StoryType), s.Id, s.Title, s.State)
		a.Title = fmt.Sprintf("Task #%s - %s\n", s.Id, s.Title)
		a.TitleLink = fmt.Sprintf(
			"https://app.mavenlink.com/workspaces/%s/#tracker/%s",
			s.WorkspaceId, s.Id)
		a.Text = strings.Title(s.State)

		if s.Users != nil && len(s.Users) > 0 {
			assignees := ""
			for _, u := range s.Users {
				if assignees != "" {
					assignees += ", "
				}
				assignees += u.Name
			}
			a.Text += " - Assignees: " + assignees
		}

		if s.TimeEstimateInMinutes > 0 {
			a.Text += fmt.Sprintf(" - Estimated hours: %s",
				utils.FormatHour(s.TimeEstimateInMinutes))
		}

		if s.LoggedBillableTimeInMinutes > 0 {
			a.Text += fmt.Sprintf(" - Logged hours: %s",
				utils.FormatHour(s.LoggedBillableTimeInMinutes))
		}

		atts = append(atts, a)
	}

	return atts
}
Esempio n. 2
0
func FmtAttachment(fallback, title, url, text string) robots.Attachment {
	a := robots.Attachment{}
	a.Color = "#7CD197"
	a.Fallback = fallback
	a.Title = title
	a.TitleLink = url
	if text != "" {
		a.Text = text
	}
	return a
}