github.com/mongodb/grip@v0.0.0-20240213223901-f906268d82b9/message/jira_comment.go (about) 1 package message 2 3 import ( 4 "github.com/mongodb/grip/level" 5 ) 6 7 type jiraComment struct { 8 Payload JIRAComment `bson:"payload" json:"payload" yaml:"payload"` 9 10 Base `bson:"metadata" json:"metadata" yaml:"metadata"` 11 } 12 13 // JIRAComment represents a single comment to post to the given JIRA issue 14 type JIRAComment struct { 15 IssueID string `bson:"issue_id,omitempty" json:"issue_id,omitempty" yaml:"issue_id,omitempty"` 16 Body string `bson:"body" json:"body" yaml:"body"` 17 } 18 19 // NewJIRACommentMessage returns a self-contained composer for posting a comment 20 // to a single JIRA issue. This composer will override the issue set in the 21 // JIRA sender 22 func NewJIRACommentMessage(p level.Priority, issueID, body string) Composer { 23 s := MakeJIRACommentMessage(issueID, body) 24 _ = s.SetPriority(p) 25 26 return s 27 } 28 29 // MakeJIRACommentMessage returns a self-contained composer for posting a comment 30 // to a single JIRA issue. This composer will override the issue set in the 31 // JIRA sender. The composer will not have a priority set 32 func MakeJIRACommentMessage(issueID, body string) Composer { 33 return &jiraComment{ 34 Payload: JIRAComment{ 35 IssueID: issueID, 36 Body: body, 37 }, 38 } 39 } 40 41 func (c *jiraComment) Loggable() bool { 42 return len(c.Payload.IssueID) > 0 && len(c.Payload.Body) > 0 43 } 44 45 func (c *jiraComment) String() string { 46 return c.Payload.Body 47 } 48 49 func (c *jiraComment) Raw() interface{} { 50 return &c.Payload 51 }