Skip to content

Add user notifications settings tab #31086

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,8 @@ LEVEL = Info
;;
;; Default configuration for email notifications for users (user configurable). Options: enabled, onmention, disabled
;DEFAULT_EMAIL_NOTIFICATIONS = enabled
;; Default configuration for UI notifications for users (user configurable). Options: enabled, onmention, disabled
;DEFAULT_UI_NOTIFICATIONS = enabled
;; Disabled features for users, could be "deletion", "manage_ssh_keys","manage_gpg_keys" more features can be disabled in future
;; - deletion: a user cannot delete their own account
;; - manage_ssh_keys: a user cannot configure ssh keys
Expand Down
1 change: 1 addition & 0 deletions docs/content/administration/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ And the following unique queues:
## Admin (`admin`)

- `DEFAULT_EMAIL_NOTIFICATIONS`: **enabled**: Default configuration for email notifications for users (user configurable). Options: enabled, onmention, disabled
- `DEFAULT_UI_NOTIFICATIONS`: **enabled**: Default configuration for UI notifications for users (user configurable). Options: enabled, onmention, disabled
- `DISABLE_REGULAR_ORG_CREATION`: **false**: Disallow regular (non-admin) users from creating organizations.
- `USER_DISABLED_FEATURES`: **_empty_** Disabled features for users, could be `deletion`, `manage_ssh_keys`, `manage_gpg_keys` and more features can be added in future.
- `deletion`: User cannot delete their own account.
Expand Down
8 changes: 8 additions & 0 deletions models/activities/notification_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ func createOrUpdateIssueNotifications(ctx context.Context, issueID, commentID, n
continue
}

// Filter users by their notification preference.
// At this point we exclude:
// user that don't have all notifications enabled or users only get notification on mention and this is one ...
if !(user.UINotificationsPreference == user_model.NotificationsEnabled ||
user.UINotificationsPreference == user_model.NotificationsOnMention) {
continue
}

if notificationExists(notifications, issue.ID, userID) {
if err = updateIssueNotification(ctx, userID, issue.ID, commentID, notificationAuthorID); err != nil {
return err
Expand Down
41 changes: 41 additions & 0 deletions models/fixtures/user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
email: user1@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -45,6 +46,7 @@
email: user2@example.com
keep_email_private: true
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -82,6 +84,7 @@
email: org3@example.com
keep_email_private: false
email_notifications_preference: onmention
ui_notifications_preference: onmention
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -119,6 +122,7 @@
email: user4@example.com
keep_email_private: false
email_notifications_preference: onmention
ui_notifications_preference: onmention
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -156,6 +160,7 @@
email: user5@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -193,6 +198,7 @@
email: org6@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -230,6 +236,7 @@
email: org7@example.com
keep_email_private: false
email_notifications_preference: disabled
ui_notifications_preference: disabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -267,6 +274,7 @@
email: user8@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -304,6 +312,7 @@
email: user9@example.com
keep_email_private: false
email_notifications_preference: onmention
ui_notifications_preference: onmention
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -341,6 +350,7 @@
email: user10@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -378,6 +388,7 @@
email: user11@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -415,6 +426,7 @@
email: user12@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -452,6 +464,7 @@
email: user13@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -489,6 +502,7 @@
email: user14@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -526,6 +540,7 @@
email: user15@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -563,6 +578,7 @@
email: user16@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -600,6 +616,7 @@
email: org17@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -637,6 +654,7 @@
email: user18@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -674,6 +692,7 @@
email: org19@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -711,6 +730,7 @@
email: user20@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -748,6 +768,7 @@
email: user21@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -785,6 +806,7 @@
email: limited_org@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -822,6 +844,7 @@
email: privated_org@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -859,6 +882,7 @@
email: user24@example.com
keep_email_private: true
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -896,6 +920,7 @@
email: org25@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -933,6 +958,7 @@
email: org26@example.com
keep_email_private: false
email_notifications_preference: onmention
ui_notifications_preference: onmention
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -970,6 +996,7 @@
email: user27@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1007,6 +1034,7 @@
email: user28@example.com
keep_email_private: true
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1044,6 +1072,7 @@
email: user29@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1081,6 +1110,7 @@
email: user30@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1118,6 +1148,7 @@
email: user31@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1155,6 +1186,7 @@
email: user32@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:notpassword
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1192,6 +1224,7 @@
email: user33@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1230,6 +1263,7 @@
email: user34@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1267,6 +1301,7 @@
email: private_org35@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1304,6 +1339,7 @@
email: abcde@gitea.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1341,6 +1377,7 @@
email: user37@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1378,6 +1415,7 @@
email: user38@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1415,6 +1453,7 @@
email: user39@example.com
keep_email_private: false
email_notifications_preference: enabled
ui_notifications_preference: enabled
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1452,6 +1491,7 @@
email: user40@example.com
keep_email_private: false
email_notifications_preference: onmention
ui_notifications_preference: onmention
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down Expand Up @@ -1489,6 +1529,7 @@
email: org41@example.com
keep_email_private: false
email_notifications_preference: onmention
ui_notifications_preference: onmention
passwd: ZogKvWdyEx:password
passwd_hash_algo: dummy
must_change_password: false
Expand Down
Loading
Loading