-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add Ability for User to Customize Email Notification Frequency #7813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lafriks
merged 15 commits into
go-gitea:master
from
gary-kim:enh/noid/disable-email-notifications
Aug 29, 2019
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fd51209
Add Backend Logic for Toggling Email Notification
gary-kim 3a3e115
Add UI and complete user email notification enable
gary-kim 564132f
Add Third Option for Only Email on Mention
gary-kim a21e094
Readd NOT NULL to new preference string
gary-kim 1bdef76
Add Tests and Rewrite Comment
gary-kim c75d312
Allow admin to set default email frequency
gary-kim c99da37
Add new config option to docs
gary-kim 9e211bb
Fix a few mistakes
gary-kim a43f8d0
Only update required columns
gary-kim f480285
Simplify an error check
lafriks 33c833d
Make email_notification_preference column in DB be VARCHAR(20)
gary-kim 7cace04
Handle errors
gary-kim fa5e8ae
Merge branch 'master' into enh/noid/disable-email-notifications
lafriks b883cbb
Update models/migrations/v93.go
gary-kim fe9ba4b
Merge branch 'master' into enh/noid/disable-email-notifications
lafriks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
name: user1 | ||
full_name: User One | ||
email: [email protected] | ||
email_notifications_preference: enabled | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 0 # individual | ||
salt: ZogKvWdyEx | ||
|
@@ -22,6 +23,7 @@ | |
full_name: " < U<se>r Tw<o > >< " | ||
email: [email protected] | ||
keep_email_private: true | ||
email_notifications_preference: enabled | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 0 # individual | ||
salt: ZogKvWdyEx | ||
|
@@ -40,6 +42,7 @@ | |
name: user3 | ||
full_name: " <<<< >> >> > >> > >>> >> " | ||
email: [email protected] | ||
email_notifications_preference: onmention | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 1 # organization | ||
salt: ZogKvWdyEx | ||
|
@@ -56,6 +59,7 @@ | |
name: user4 | ||
full_name: " " | ||
email: [email protected] | ||
email_notifications_preference: onmention | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 0 # individual | ||
salt: ZogKvWdyEx | ||
|
@@ -72,6 +76,7 @@ | |
name: user5 | ||
full_name: User Five | ||
email: [email protected] | ||
email_notifications_preference: enabled | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 0 # individual | ||
salt: ZogKvWdyEx | ||
|
@@ -89,6 +94,7 @@ | |
name: user6 | ||
full_name: User Six | ||
email: [email protected] | ||
email_notifications_preference: enabled | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 1 # organization | ||
salt: ZogKvWdyEx | ||
|
@@ -105,6 +111,7 @@ | |
name: user7 | ||
full_name: User Seven | ||
email: [email protected] | ||
email_notifications_preference: disabled | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 1 # organization | ||
salt: ZogKvWdyEx | ||
|
@@ -121,6 +128,7 @@ | |
name: user8 | ||
full_name: User Eight | ||
email: [email protected] | ||
email_notifications_preference: enabled | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 0 # individual | ||
salt: ZogKvWdyEx | ||
|
@@ -138,6 +146,7 @@ | |
name: user9 | ||
full_name: User Nine | ||
email: [email protected] | ||
email_notifications_preference: onmention | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 0 # individual | ||
salt: ZogKvWdyEx | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2019 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package migrations | ||
|
||
import "github.com/go-xorm/xorm" | ||
|
||
func addEmailNotificationEnabledToUser(x *xorm.Engine) error { | ||
// User see models/user.go | ||
type User struct { | ||
EmailNotificationsPreference string `xorm:"VARCHAR(20) NOT NULL DEFAULT 'enabled'"` | ||
} | ||
|
||
return x.Sync2(new(User)) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,8 @@ func TestGetUserEmailsByNames(t *testing.T) { | |
// ignore none active user email | ||
assert.Equal(t, []string{"[email protected]"}, GetUserEmailsByNames([]string{"user8", "user9"})) | ||
assert.Equal(t, []string{"[email protected]", "[email protected]"}, GetUserEmailsByNames([]string{"user8", "user5"})) | ||
|
||
assert.Equal(t, []string{"[email protected]"}, GetUserEmailsByNames([]string{"user8", "user7"})) | ||
} | ||
|
||
func TestUser_APIFormat(t *testing.T) { | ||
|
@@ -196,6 +198,37 @@ func TestDeleteUser(t *testing.T) { | |
test(11) | ||
} | ||
|
||
func TestEmailNotificationPreferences(t *testing.T) { | ||
assert.NoError(t, PrepareTestDatabase()) | ||
for _, test := range []struct { | ||
expected string | ||
userID int64 | ||
}{ | ||
{EmailNotificationsEnabled, 1}, | ||
{EmailNotificationsEnabled, 2}, | ||
{EmailNotificationsOnMention, 3}, | ||
{EmailNotificationsOnMention, 4}, | ||
{EmailNotificationsEnabled, 5}, | ||
{EmailNotificationsEnabled, 6}, | ||
{EmailNotificationsDisabled, 7}, | ||
{EmailNotificationsEnabled, 8}, | ||
{EmailNotificationsOnMention, 9}, | ||
} { | ||
user := AssertExistsAndLoadBean(t, &User{ID: test.userID}).(*User) | ||
assert.Equal(t, test.expected, user.EmailNotifications()) | ||
|
||
// Try all possible settings | ||
assert.NoError(t, user.SetEmailNotifications(EmailNotificationsEnabled)) | ||
assert.Equal(t, EmailNotificationsEnabled, user.EmailNotifications()) | ||
|
||
assert.NoError(t, user.SetEmailNotifications(EmailNotificationsOnMention)) | ||
assert.Equal(t, EmailNotificationsOnMention, user.EmailNotifications()) | ||
|
||
assert.NoError(t, user.SetEmailNotifications(EmailNotificationsDisabled)) | ||
assert.Equal(t, EmailNotificationsDisabled, user.EmailNotifications()) | ||
} | ||
} | ||
|
||
func TestHashPasswordDeterministic(t *testing.T) { | ||
b := make([]byte, 16) | ||
rand.Read(b) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2013,7 +2013,7 @@ | |
|
||
.list { | ||
> .item { | ||
.green { | ||
.green:not(.ui.button) { | ||
color: #21ba45; | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.