summaryrefslogtreecommitdiffstats
path: root/models/issue.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/issue.go')
-rw-r--r--models/issue.go47
1 files changed, 22 insertions, 25 deletions
diff --git a/models/issue.go b/models/issue.go
index 8d0525d7c5..3cd71d8aa4 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -282,30 +282,33 @@ type IssueUser struct {
}
// NewIssueUserPairs adds new issue-user pairs for new issue of repository.
-func NewIssueUserPairs(repo *Repository, iid, oid, pid, aid int64) (err error) {
- iu := &IssueUser{IssueId: iid, RepoId: repo.Id}
-
- us, err := repo.GetCollaborators()
+func NewIssueUserPairs(repo *Repository, issueID, orgID, posterID, assigneeID int64) (err error) {
+ users, err := repo.GetCollaborators()
if err != nil {
return err
}
+ iu := &IssueUser{
+ IssueId: issueID,
+ RepoId: repo.Id,
+ }
+
isNeedAddPoster := true
- for _, u := range us {
+ for _, u := range users {
iu.Uid = u.Id
- iu.IsPoster = iu.Uid == pid
+ iu.IsPoster = iu.Uid == posterID
if isNeedAddPoster && iu.IsPoster {
isNeedAddPoster = false
}
- iu.IsAssigned = iu.Uid == aid
+ iu.IsAssigned = iu.Uid == assigneeID
if _, err = x.Insert(iu); err != nil {
return err
}
}
if isNeedAddPoster {
- iu.Uid = pid
+ iu.Uid = posterID
iu.IsPoster = true
- iu.IsAssigned = iu.Uid == aid
+ iu.IsAssigned = iu.Uid == assigneeID
if _, err = x.Insert(iu); err != nil {
return err
}
@@ -859,22 +862,16 @@ type CommentType int
const (
// Plain comment, can be associated with a commit (CommitId > 0) and a line (Line > 0)
- COMMENT CommentType = iota
-
- // Reopen action
- REOPEN
-
- // Close action
- CLOSE
-
- // Reference from another issue
- ISSUE
+ COMMENT_TYPE_COMMENT CommentType = iota
+ COMMENT_TYPE_REOPEN
+ COMMENT_TYPE_CLOSE
+ // References.
+ COMMENT_TYPE_ISSUE
// Reference from some commit (not part of a pull request)
- COMMIT
-
+ COMMENT_TYPE_COMMIT
// Reference from some pull request
- PULL
+ COMMENT_TYPE_PULL
)
// Comment represents a comment in commit and issue page.
@@ -908,7 +905,7 @@ func CreateComment(userId, repoId, issueId, commitId, line int64, cmtType Commen
// Check comment type.
switch cmtType {
- case COMMENT:
+ case COMMENT_TYPE_COMMENT:
rawSql := "UPDATE `issue` SET num_comments = num_comments + 1 WHERE id = ?"
if _, err := sess.Exec(rawSql, issueId); err != nil {
sess.Rollback()
@@ -929,13 +926,13 @@ func CreateComment(userId, repoId, issueId, commitId, line int64, cmtType Commen
return nil, err
}
}
- case REOPEN:
+ case COMMENT_TYPE_REOPEN:
rawSql := "UPDATE `repository` SET num_closed_issues = num_closed_issues - 1 WHERE id = ?"
if _, err := sess.Exec(rawSql, repoId); err != nil {
sess.Rollback()
return nil, err
}
- case CLOSE:
+ case COMMENT_TYPE_CLOSE:
rawSql := "UPDATE `repository` SET num_closed_issues = num_closed_issues + 1 WHERE id = ?"
if _, err := sess.Exec(rawSql, repoId); err != nil {
sess.Rollback()