diff options
author | guillep2k <18600385+guillep2k@users.noreply.github.com> | 2019-11-18 05:08:20 -0300 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-11-18 08:08:20 +0000 |
commit | 08ae6bb7edb9582c38edb8a0dba1b1be10fb00fc (patch) | |
tree | c64e9a1c9cfaeb6cd0c2ee012d3ad32c38e78ce3 /models/issue_watch.go | |
parent | 9ff63126274b0df6e035541eafd48970c402e61e (diff) | |
download | gitea-08ae6bb7edb9582c38edb8a0dba1b1be10fb00fc.tar.gz gitea-08ae6bb7edb9582c38edb8a0dba1b1be10fb00fc.zip |
Rewrite delivery of issue and comment mails (#9009)
* Mail issue subscribers, rework the function
* Simplify a little more
* Fix unused variable
* Refactor mail delivery to avoid heavy load on server
* Avoid splitting into too many goroutines
* Fix comments and optimize GetMaileableUsersByIDs()
* Fix return on errors
Diffstat (limited to 'models/issue_watch.go')
-rw-r--r-- | models/issue_watch.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/models/issue_watch.go b/models/issue_watch.go index 1ae0c9d474..3d7d48a125 100644 --- a/models/issue_watch.go +++ b/models/issue_watch.go @@ -60,6 +60,18 @@ func getIssueWatch(e Engine, userID, issueID int64) (iw *IssueWatch, exists bool return } +// GetIssueWatchersIDs returns IDs of subscribers to a given issue id +// but avoids joining with `user` for performance reasons +// User permissions must be verified elsewhere if required +func GetIssueWatchersIDs(issueID int64) ([]int64, error) { + ids := make([]int64, 0, 64) + return ids, x.Table("issue_watch"). + Where("issue_id=?", issueID). + And("is_watching = ?", true). + Select("user_id"). + Find(&ids) +} + // GetIssueWatchers returns watchers/unwatchers of a given issue func GetIssueWatchers(issueID int64) (IssueWatchList, error) { return getIssueWatchers(x, issueID) |