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/user.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/user.go')
-rw-r--r-- | models/user.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/models/user.go b/models/user.go index 4a8c644ccd..ce78e5bfce 100644 --- a/models/user.go +++ b/models/user.go @@ -1307,6 +1307,20 @@ func getUserEmailsByNames(e Engine, names []string) []string { return mails } +// GetMaileableUsersByIDs gets users from ids, but only if they can receive mails +func GetMaileableUsersByIDs(ids []int64) ([]*User, error) { + if len(ids) == 0 { + return nil, nil + } + ous := make([]*User, 0, len(ids)) + return ous, x.In("id", ids). + Where("`type` = ?", UserTypeIndividual). + And("`prohibit_login` = ?", false). + And("`is_active` = ?", true). + And("`email_notifications_preference` = ?", EmailNotificationsEnabled). + Find(&ous) +} + // GetUsersByIDs returns all resolved users from a list of Ids. func GetUsersByIDs(ids []int64) ([]*User, error) { ous := make([]*User, 0, len(ids)) |