aboutsummaryrefslogtreecommitdiffstats
path: root/models/user.go
diff options
context:
space:
mode:
author赵智超 <1012112796@qq.com>2020-09-10 03:08:55 +0800
committerGitHub <noreply@github.com>2020-09-09 15:08:55 -0400
commitffa12bdb71d1e708ff782fb681895aea9b83766b (patch)
tree52631f50e83c2e0b5db67d3bb5df3be437bb7f31 /models/user.go
parent0cd49aaebd0434cffaf16e557620441a50bb757d (diff)
downloadgitea-ffa12bdb71d1e708ff782fb681895aea9b83766b.tar.gz
gitea-ffa12bdb71d1e708ff782fb681895aea9b83766b.zip
Fix "only mail on mention" bug (#12775)
* fix mail mention bug fix #12774 Signed-off-by: a1012112796 <1012112796@qq.com> * fix test Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'models/user.go')
-rw-r--r--models/user.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/models/user.go b/models/user.go
index 2e5d6473bb..c7b3f0981e 100644
--- a/models/user.go
+++ b/models/user.go
@@ -1419,11 +1419,21 @@ func getUserEmailsByNames(e Engine, names []string) []string {
}
// GetMaileableUsersByIDs gets users from ids, but only if they can receive mails
-func GetMaileableUsersByIDs(ids []int64) ([]*User, error) {
+func GetMaileableUsersByIDs(ids []int64, isMention bool) ([]*User, error) {
if len(ids) == 0 {
return nil, nil
}
ous := make([]*User, 0, len(ids))
+
+ if isMention {
+ return ous, x.In("id", ids).
+ Where("`type` = ?", UserTypeIndividual).
+ And("`prohibit_login` = ?", false).
+ And("`is_active` = ?", true).
+ And("`email_notifications_preference` IN ( ?, ?)", EmailNotificationsEnabled, EmailNotificationsOnMention).
+ Find(&ous)
+ }
+
return ous, x.In("id", ids).
Where("`type` = ?", UserTypeIndividual).
And("`prohibit_login` = ?", false).