diff --git a/azuredevops/azuredevops.go b/azuredevops/azuredevops.go index 8bb0ddf..76b8fae 100644 --- a/azuredevops/azuredevops.go +++ b/azuredevops/azuredevops.go @@ -27,6 +27,7 @@ const ( GitPullRequestUpdatedEventType Event = "git.pullrequest.updated" GitPullRequestMergedEventType Event = "git.pullrequest.merged" GitPushEventType Event = "git.push" + GitPullRequestCommentEventType Event = "ms.vss-code.git-pullrequest-comment-event" ) // Webhook instance contains all methods needed to process events @@ -74,6 +75,10 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) var fpl BuildCompleteEvent err = json.Unmarshal([]byte(payload), &fpl) return fpl, err + case GitPullRequestCommentEventType: + var fpl GitPullRequestCommentEvent + err = json.Unmarshal([]byte(payload), &fpl) + return fpl, err default: return nil, fmt.Errorf("unknown event %s", pl.EventType) } diff --git a/azuredevops/payload.go b/azuredevops/payload.go index 8554752..ec56834 100644 --- a/azuredevops/payload.go +++ b/azuredevops/payload.go @@ -51,6 +51,17 @@ type GitPushEvent struct { Scope string `json:"scope"` } +// "ms.vss-code.git-pullrequest-comment-event" + +type GitPullRequestCommentEvent struct { + ID string `json:"id"` + EventType Event `json:"eventType"` + PublisherID string `json:"publisherId"` + Scope string `json:"scope"` + Message Message `json:"message"` + Resource PullRequestComment `json:"resource"` +} + // build.complete type BuildCompleteEvent struct { @@ -100,6 +111,22 @@ type PullRequest struct { URL string `json:"url"` } +type PullRequestComment struct { + PullRequest PullRequest `json:"pullRequest"` + Comment Comment `json:"comment"` +} + +type Comment struct { + ID int `json:"id"` + ParentCommentID int `json:"parentCommentId"` + Content string `json:"content"` + Author User `json:"author"` + PublishedDate Date `json:"publishedDate"` + LastUpdatedDate Date `json:"lastUpdatedDate"` + LastContentUpdatedDate Date `json:"lastContentUpdatedDate"` + CommentType string `json:"commentType"` +} + type Repository struct { ID string `json:"id"` Name string `json:"name"`