diff options
author | Tyrone Yeh <siryeh@gmail.com> | 2022-07-28 16:30:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-28 16:30:12 +0800 |
commit | 3bd8f50af819b8dfc86b9fecdfc36ca7774c6a2d (patch) | |
tree | ffa9a1e950cb96602e7057d73e9b2dc795357ac9 /models | |
parent | 86e5268c396bd89716b2617a4949837982c1b0c3 (diff) | |
download | gitea-3bd8f50af819b8dfc86b9fecdfc36ca7774c6a2d.tar.gz gitea-3bd8f50af819b8dfc86b9fecdfc36ca7774c6a2d.zip |
Added email notification option to receive all own messages (#20179)
Sometimes users want to receive email notifications of messages they create or reply to,
Added an option to personal preferences to allow users to choose
Closes #20149
Diffstat (limited to 'models')
-rw-r--r-- | models/user/user.go | 8 | ||||
-rw-r--r-- | models/user/user_test.go | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/models/user/user.go b/models/user/user.go index fbd8df9472..91eeeb8962 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -64,12 +64,14 @@ var AvailableHashAlgorithms = []string{ } const ( - // EmailNotificationsEnabled indicates that the user would like to receive all email notifications + // EmailNotificationsEnabled indicates that the user would like to receive all email notifications except your own EmailNotificationsEnabled = "enabled" // EmailNotificationsOnMention indicates that the user would like to be notified via email when mentioned. EmailNotificationsOnMention = "onmention" // EmailNotificationsDisabled indicates that the user would not like to be notified via email. EmailNotificationsDisabled = "disabled" + // EmailNotificationsEnabled indicates that the user would like to receive all email notifications and your own + EmailNotificationsAndYourOwn = "andyourown" ) // User represents the object of individual and member of organization. @@ -1045,7 +1047,7 @@ func GetMaileableUsersByIDs(ids []int64, isMention bool) ([]*User, error) { Where("`type` = ?", UserTypeIndividual). And("`prohibit_login` = ?", false). And("`is_active` = ?", true). - And("`email_notifications_preference` IN ( ?, ?)", EmailNotificationsEnabled, EmailNotificationsOnMention). + In("`email_notifications_preference`", EmailNotificationsEnabled, EmailNotificationsOnMention, EmailNotificationsAndYourOwn). Find(&ous) } @@ -1053,7 +1055,7 @@ func GetMaileableUsersByIDs(ids []int64, isMention bool) ([]*User, error) { Where("`type` = ?", UserTypeIndividual). And("`prohibit_login` = ?", false). And("`is_active` = ?", true). - And("`email_notifications_preference` = ?", EmailNotificationsEnabled). + In("`email_notifications_preference`", EmailNotificationsEnabled, EmailNotificationsAndYourOwn). Find(&ous) } diff --git a/models/user/user_test.go b/models/user/user_test.go index 4994ac53ab..489ee3b05d 100644 --- a/models/user/user_test.go +++ b/models/user/user_test.go @@ -153,6 +153,9 @@ func TestEmailNotificationPreferences(t *testing.T) { assert.NoError(t, user_model.SetEmailNotifications(user, user_model.EmailNotificationsDisabled)) assert.Equal(t, user_model.EmailNotificationsDisabled, user.EmailNotifications()) + + assert.NoError(t, user_model.SetEmailNotifications(user, user_model.EmailNotificationsAndYourOwn)) + assert.Equal(t, user_model.EmailNotificationsAndYourOwn, user.EmailNotifications()) } } |