// NewMessage converts a job and event type to a message that can be send // through a websocket. func NewMessage(job *database.Job, event string) *Message { return &Message{ Name: job.Name, Email: job.Email, Event: event, RepositoryName: job.Repository.Name, Branch: job.Branch, Status: job.Status(), URL: job.URL(), } }
// emailSubject returns the subject for an email. func emailSubject(job *database.Job, event string) string { if event == EventBuild { return fmt.Sprintf("%s/%s build", job.Repository.Name, job.Branch) } if event == EventTest { return fmt.Sprintf("%s/%s tests", job.Repository.Name, job.Branch) } if event == EventDeployStart { return fmt.Sprintf("%s/%s deployment started", job.Repository.Name, job.Branch) } if event == EventDeployEnd { return fmt.Sprintf("%s/%s deploy %s", job.Repository.Name, job.Branch, job.Status()) } return "LeeroyCI is confused - not sure which message this is." }