diff --git a/appview/db/db.go b/appview/db/db.go --- a/appview/db/db.go +++ b/appview/db/db.go @@ -1121,6 +1121,13 @@ return err }) + runMigration(conn, logger, "add-usermentioned-preference", func(tx *sql.Tx) error { + _, err := tx.Exec(` + alter table notification_preferences add column user_mentioned integer not null default 1; + `) + return err + }) + return &DB{ db, logger, diff --git a/appview/db/notifications.go b/appview/db/notifications.go --- a/appview/db/notifications.go +++ b/appview/db/notifications.go @@ -400,6 +400,7 @@ pull_created, pull_commented, followed, + user_mentioned, pull_merged, issue_closed, email_notifications @@ -425,6 +426,7 @@ &prefs.PullCreated, &prefs.PullCommented, &prefs.Followed, + &prefs.UserMentioned, &prefs.PullMerged, &prefs.IssueClosed, &prefs.EmailNotifications, @@ -446,8 +448,9 @@ query := ` INSERT OR REPLACE INTO notification_preferences (user_did, repo_starred, issue_created, issue_commented, pull_created, - pull_commented, followed, pull_merged, issue_closed, email_notifications) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + pull_commented, followed, user_mentioned, pull_merged, issue_closed, + email_notifications) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ` result, err := d.DB.ExecContext(ctx, query, @@ -458,6 +461,7 @@ prefs.PullCreated, prefs.PullCommented, prefs.Followed, + prefs.UserMentioned, prefs.PullMerged, prefs.IssueClosed, prefs.EmailNotifications, diff --git a/appview/models/notifications.go b/appview/models/notifications.go --- a/appview/models/notifications.go +++ b/appview/models/notifications.go @@ -87,6 +87,7 @@ PullCreated bool PullCommented bool Followed bool + UserMentioned bool PullMerged bool IssueClosed bool EmailNotifications bool @@ -117,7 +118,7 @@ case NotificationTypeFollowed: return prefs.Followed case NotificationTypeUserMentioned: - return true // always notify on mention + return prefs.UserMentioned default: return false } @@ -132,6 +133,7 @@ PullCreated: true, PullCommented: true, Followed: true, + UserMentioned: true, PullMerged: true, IssueClosed: true, EmailNotifications: false, diff --git a/appview/settings/settings.go b/appview/settings/settings.go --- a/appview/settings/settings.go +++ b/appview/settings/settings.go @@ -120,6 +120,7 @@ PullCommented: r.FormValue("pull_commented") == "on", PullMerged: r.FormValue("pull_merged") == "on", Followed: r.FormValue("followed") == "on", + UserMentioned: r.FormValue("user_mentioned") == "on", EmailNotifications: r.FormValue("email_notifications") == "on", } diff --git a/appview/pages/templates/user/settings/notifications.html b/appview/pages/templates/user/settings/notifications.html --- a/appview/pages/templates/user/settings/notifications.html +++ b/appview/pages/templates/user/settings/notifications.html @@ -144,6 +144,20 @@