summaryrefslogtreecommitdiffstats
path: root/modules/structs
diff options
context:
space:
mode:
author谈笑风生间 <makonike@anyview.fun>2023-05-25 10:06:27 +0800
committerGitHub <noreply@github.com>2023-05-24 22:06:27 -0400
commit309354c70ee994a1e8f261d7bc24e7473e601d02 (patch)
tree89a96f611eef8b37e17dcead9767ff8d9ba976ef /modules/structs
parent93c6a9a652460f89fc719024c435cacbb235d302 (diff)
downloadgitea-309354c70ee994a1e8f261d7bc24e7473e601d02.tar.gz
gitea-309354c70ee994a1e8f261d7bc24e7473e601d02.zip
New webhook trigger for receiving Pull Request review requests (#24481)
close https://github.com/go-gitea/gitea/issues/16321 Provided a webhook trigger for requesting someone to review the Pull Request. Some modifications have been made to the returned `PullRequestPayload` based on the GitHub webhook settings, including: - add a description of the current reviewer object as `RequestedReviewer` . - setting the action to either **review_requested** or **review_request_removed** based on the operation. - adding the `RequestedReviewers` field to the issues_model.PullRequest. This field will be loaded into the PullRequest through `LoadRequestedReviewers()` when `ToAPIPullRequest` is called. After the Pull Request is merged, I will supplement the relevant documentation.
Diffstat (limited to 'modules/structs')
-rw-r--r--modules/structs/hook.go21
-rw-r--r--modules/structs/pull.go27
2 files changed, 27 insertions, 21 deletions
diff --git a/modules/structs/hook.go b/modules/structs/hook.go
index df5da6790f..cd91d4bc46 100644
--- a/modules/structs/hook.go
+++ b/modules/structs/hook.go
@@ -342,6 +342,10 @@ const (
HookIssueDemilestoned HookIssueAction = "demilestoned"
// HookIssueReviewed is an issue action for when a pull request is reviewed
HookIssueReviewed HookIssueAction = "reviewed"
+ // HookIssueReviewRequested is an issue action for when a reviewer is requested for a pull request.
+ HookIssueReviewRequested HookIssueAction = "review_requested"
+ // HookIssueReviewRequestRemoved is an issue action for removing a review request to someone on a pull request.
+ HookIssueReviewRequestRemoved HookIssueAction = "review_request_removed"
)
// IssuePayload represents the payload information that is sent along with an issue event.
@@ -381,14 +385,15 @@ type ChangesPayload struct {
// PullRequestPayload represents a payload information of pull request event.
type PullRequestPayload struct {
- Action HookIssueAction `json:"action"`
- Index int64 `json:"number"`
- Changes *ChangesPayload `json:"changes,omitempty"`
- PullRequest *PullRequest `json:"pull_request"`
- Repository *Repository `json:"repository"`
- Sender *User `json:"sender"`
- CommitID string `json:"commit_id"`
- Review *ReviewPayload `json:"review"`
+ Action HookIssueAction `json:"action"`
+ Index int64 `json:"number"`
+ Changes *ChangesPayload `json:"changes,omitempty"`
+ PullRequest *PullRequest `json:"pull_request"`
+ RequestedReviewer *User `json:"requested_reviewer"`
+ Repository *Repository `json:"repository"`
+ Sender *User `json:"sender"`
+ CommitID string `json:"commit_id"`
+ Review *ReviewPayload `json:"review"`
}
// JSONPayload FIXME
diff --git a/modules/structs/pull.go b/modules/structs/pull.go
index f64bb83af9..a4a6f60b05 100644
--- a/modules/structs/pull.go
+++ b/modules/structs/pull.go
@@ -9,19 +9,20 @@ import (
// PullRequest represents a pull request
type PullRequest struct {
- ID int64 `json:"id"`
- URL string `json:"url"`
- Index int64 `json:"number"`
- Poster *User `json:"user"`
- Title string `json:"title"`
- Body string `json:"body"`
- Labels []*Label `json:"labels"`
- Milestone *Milestone `json:"milestone"`
- Assignee *User `json:"assignee"`
- Assignees []*User `json:"assignees"`
- State StateType `json:"state"`
- IsLocked bool `json:"is_locked"`
- Comments int `json:"comments"`
+ ID int64 `json:"id"`
+ URL string `json:"url"`
+ Index int64 `json:"number"`
+ Poster *User `json:"user"`
+ Title string `json:"title"`
+ Body string `json:"body"`
+ Labels []*Label `json:"labels"`
+ Milestone *Milestone `json:"milestone"`
+ Assignee *User `json:"assignee"`
+ Assignees []*User `json:"assignees"`
+ RequestedReviewers []*User `json:"requested_reviewers"`
+ State StateType `json:"state"`
+ IsLocked bool `json:"is_locked"`
+ Comments int `json:"comments"`
HTMLURL string `json:"html_url"`
DiffURL string `json:"diff_url"`