(e *xorm.Session, repo *Repository, issue *Issue)
| 1049 | } |
| 1050 | |
| 1051 | func newIssueUsers(e *xorm.Session, repo *Repository, issue *Issue) error { |
| 1052 | assignees, err := repo.getAssignees(e) |
| 1053 | if err != nil { |
| 1054 | return errors.Newf("getAssignees: %v", err) |
| 1055 | } |
| 1056 | |
| 1057 | // Poster can be anyone, append later if not one of assignees. |
| 1058 | isPosterAssignee := false |
| 1059 | |
| 1060 | // Leave a seat for poster itself to append later, but if poster is one of assignee |
| 1061 | // and just waste 1 unit is cheaper than re-allocate memory once. |
| 1062 | issueUsers := make([]*IssueUser, 0, len(assignees)+1) |
| 1063 | for _, assignee := range assignees { |
| 1064 | isPoster := assignee.ID == issue.PosterID |
| 1065 | issueUsers = append(issueUsers, &IssueUser{ |
| 1066 | IssueID: issue.ID, |
| 1067 | RepoID: repo.ID, |
| 1068 | UserID: assignee.ID, |
| 1069 | IsPoster: isPoster, |
| 1070 | IsAssigned: assignee.ID == issue.AssigneeID, |
| 1071 | }) |
| 1072 | if !isPosterAssignee && isPoster { |
| 1073 | isPosterAssignee = true |
| 1074 | } |
| 1075 | } |
| 1076 | if !isPosterAssignee { |
| 1077 | issueUsers = append(issueUsers, &IssueUser{ |
| 1078 | IssueID: issue.ID, |
| 1079 | RepoID: repo.ID, |
| 1080 | UserID: issue.PosterID, |
| 1081 | IsPoster: true, |
| 1082 | }) |
| 1083 | } |
| 1084 | |
| 1085 | if _, err = e.Insert(issueUsers); err != nil { |
| 1086 | return err |
| 1087 | } |
| 1088 | return nil |
| 1089 | } |
| 1090 | |
| 1091 | // NewIssueUsers adds new issue-user relations for new issue of repository. |
| 1092 | func NewIssueUsers(repo *Repository, issue *Issue) (err error) { |
no test coverage detected