diff options
author | Sandro Santilli <strk@kbt.io> | 2017-03-16 02:34:24 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-03-16 09:34:24 +0800 |
commit | 447c9b428f4cf50174ef7f3fbea56b5405f6bbf8 (patch) | |
tree | 9188395769273bd286e73ee940311216fce58073 /models/issue.go | |
parent | ca1c3f1926eff992a2458f26cb24ed2f35265b05 (diff) | |
download | gitea-447c9b428f4cf50174ef7f3fbea56b5405f6bbf8.tar.gz gitea-447c9b428f4cf50174ef7f3fbea56b5405f6bbf8.zip |
Send notifications to partecipants in issue comments (#1217)
* Send notifications to partecipants in issue comments
Closes #1216
Includes test (still failing)
* Do not include "labelers" to participants
Fix test to expect what GetParticipants return
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/models/issue.go b/models/issue.go index 347598300e..8de6ea9cb9 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1134,6 +1134,24 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) { return issues, nil } +// GetParticipantsByIssueID returns all users who are participated in comments of an issue. +func GetParticipantsByIssueID(issueID int64) ([]*User, error) { + userIDs := make([]int64, 0, 5) + if err := x.Table("comment").Cols("poster_id"). + Where("issue_id = ?", issueID). + And("type = ?", CommentTypeComment). + Distinct("poster_id"). + Find(&userIDs); err != nil { + return nil, fmt.Errorf("get poster IDs: %v", err) + } + if len(userIDs) == 0 { + return nil, nil + } + + users := make([]*User, 0, len(userIDs)) + return users, x.In("id", userIDs).Find(&users) +} + // UpdateIssueMentions extracts mentioned people from content and // updates issue-user relations for them. func UpdateIssueMentions(e Engine, issueID int64, mentions []string) error { |