diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2018-05-21 10:28:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-21 10:28:29 +0800 |
commit | 6bdc556b7f490be7360104b731ce817050cc1d80 (patch) | |
tree | 63887addb45b5b2be1e672580c984497fa9f4112 /models/issue_assignees.go | |
parent | dc0ef38950ec8aca78f6e870fb83d1ca68074682 (diff) | |
download | gitea-6bdc556b7f490be7360104b731ce817050cc1d80.tar.gz gitea-6bdc556b7f490be7360104b731ce817050cc1d80.zip |
Fix some webhooks bugs (#3981)
* fix some webhooks bugs
* update vendor
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* fix test
* fix clearlabels
* fix pullrequest webhook bug fix #3492
* update release webhook description
* remove unused code
* fix push webhook in pull request
* small changes
Diffstat (limited to 'models/issue_assignees.go')
-rw-r--r-- | models/issue_assignees.go | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/models/issue_assignees.go b/models/issue_assignees.go index 3e68126a6c..24773cc576 100644 --- a/models/issue_assignees.go +++ b/models/issue_assignees.go @@ -159,12 +159,16 @@ func (issue *Issue) changeAssignee(sess *xorm.Session, doer *User, assigneeID in return fmt.Errorf("createAssigneeComment: %v", err) } + mode, _ := accessLevel(sess, doer.ID, issue.Repo) if issue.IsPull { - issue.PullRequest = &PullRequest{Issue: issue} + if err = issue.loadPullRequest(sess); err != nil { + return fmt.Errorf("loadPullRequest: %v", err) + } + issue.PullRequest.Issue = issue apiPullRequest := &api.PullRequestPayload{ Index: issue.Index, PullRequest: issue.PullRequest.APIFormat(), - Repository: issue.Repo.APIFormat(AccessModeNone), + Repository: issue.Repo.APIFormat(mode), Sender: doer.APIFormat(), } if removed { @@ -172,7 +176,23 @@ func (issue *Issue) changeAssignee(sess *xorm.Session, doer *User, assigneeID in } else { apiPullRequest.Action = api.HookIssueAssigned } - if err := PrepareWebhooks(issue.Repo, HookEventPullRequest, apiPullRequest); err != nil { + if err := prepareWebhooks(sess, issue.Repo, HookEventPullRequest, apiPullRequest); err != nil { + log.Error(4, "PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err) + return nil + } + } else { + apiIssue := &api.IssuePayload{ + Index: issue.Index, + Issue: issue.APIFormat(), + Repository: issue.Repo.APIFormat(mode), + Sender: doer.APIFormat(), + } + if removed { + apiIssue.Action = api.HookIssueUnassigned + } else { + apiIssue.Action = api.HookIssueAssigned + } + if err := prepareWebhooks(sess, issue.Repo, HookEventIssues, apiIssue); err != nil { log.Error(4, "PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err) return nil } |