aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_assignees.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-10-28 10:11:50 +0800
committerGitHub <noreply@github.com>2019-10-28 10:11:50 +0800
commit495d5e4329326b27158a25b44c37986923d0bb6b (patch)
treefa8474775eb9a1bdb11380ca17a9ca42a991fcb3 /models/issue_assignees.go
parent018b0e818038f3c38cc6bfc96fadeb25c92380e6 (diff)
downloadgitea-495d5e4329326b27158a25b44c37986923d0bb6b.tar.gz
gitea-495d5e4329326b27158a25b44c37986923d0bb6b.zip
Move more issue assignee code from models to issue service (#8690)
* Move more issue assignee code from models to issue service * fix test
Diffstat (limited to 'models/issue_assignees.go')
-rw-r--r--models/issue_assignees.go73
1 files changed, 0 insertions, 73 deletions
diff --git a/models/issue_assignees.go b/models/issue_assignees.go
index ed0576b38b..e15b718eb2 100644
--- a/models/issue_assignees.go
+++ b/models/issue_assignees.go
@@ -7,9 +7,6 @@ package models
import (
"fmt"
- "code.gitea.io/gitea/modules/log"
- api "code.gitea.io/gitea/modules/structs"
-
"xorm.io/xorm"
)
@@ -65,31 +62,6 @@ func isUserAssignedToIssue(e Engine, issue *Issue, user *User) (isAssigned bool,
return e.Get(&IssueAssignees{IssueID: issue.ID, AssigneeID: user.ID})
}
-// DeleteNotPassedAssignee deletes all assignees who aren't passed via the "assignees" array
-func DeleteNotPassedAssignee(issue *Issue, doer *User, assignees []*User) (err error) {
- var found bool
-
- for _, assignee := range issue.Assignees {
-
- found = false
- for _, alreadyAssignee := range assignees {
- if assignee.ID == alreadyAssignee.ID {
- found = true
- break
- }
- }
-
- if !found {
- // This function also does comments and hooks, which is why we call it seperatly instead of directly removing the assignees here
- if _, _, err := issue.ToggleAssignee(doer, assignee.ID); err != nil {
- return err
- }
- }
- }
-
- return nil
-}
-
// MakeAssigneeList concats a string with all names of the assignees. Useful for logs.
func MakeAssigneeList(issue *Issue) (assigneeList string, err error) {
err = issue.loadAssignees(x)
@@ -131,8 +103,6 @@ func (issue *Issue) ToggleAssignee(doer *User, assigneeID int64) (removed bool,
return false, nil, err
}
- go HookQueue.Add(issue.RepoID)
-
return removed, comment, nil
}
@@ -158,49 +128,6 @@ func (issue *Issue) toggleAssignee(sess *xorm.Session, doer *User, assigneeID in
return removed, comment, err
}
- if issue.IsPull {
- mode, _ := accessLevelUnit(sess, doer, issue.Repo, UnitTypePullRequests)
-
- if err = issue.loadPullRequest(sess); err != nil {
- return false, nil, fmt.Errorf("loadPullRequest: %v", err)
- }
- issue.PullRequest.Issue = issue
- apiPullRequest := &api.PullRequestPayload{
- Index: issue.Index,
- PullRequest: issue.PullRequest.apiFormat(sess),
- Repository: issue.Repo.innerAPIFormat(sess, mode, false),
- Sender: doer.APIFormat(),
- }
- if removed {
- apiPullRequest.Action = api.HookIssueUnassigned
- } else {
- apiPullRequest.Action = api.HookIssueAssigned
- }
- // Assignee comment triggers a webhook
- if err := prepareWebhooks(sess, issue.Repo, HookEventPullRequest, apiPullRequest); err != nil {
- log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err)
- return false, nil, err
- }
- } else {
- mode, _ := accessLevelUnit(sess, doer, issue.Repo, UnitTypeIssues)
-
- apiIssue := &api.IssuePayload{
- Index: issue.Index,
- Issue: issue.apiFormat(sess),
- Repository: issue.Repo.innerAPIFormat(sess, mode, false),
- Sender: doer.APIFormat(),
- }
- if removed {
- apiIssue.Action = api.HookIssueUnassigned
- } else {
- apiIssue.Action = api.HookIssueAssigned
- }
- // Assignee comment triggers a webhook
- if err := prepareWebhooks(sess, issue.Repo, HookEventIssues, apiIssue); err != nil {
- log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err)
- return false, nil, err
- }
- }
return removed, comment, nil
}