+7
appview/db/db.go
+7
appview/db/db.go
···
1121
1121
return err
1122
1122
})
1123
1123
1124
+
runMigration(conn, logger, "add-usermentioned-preference", func(tx *sql.Tx) error {
1125
+
_, err := tx.Exec(`
1126
+
alter table notification_preferences add column user_mentioned integer not null default 1;
1127
+
`)
1128
+
return err
1129
+
})
1130
+
1124
1131
return &DB{
1125
1132
db,
1126
1133
logger,
+6
-2
appview/db/notifications.go
+6
-2
appview/db/notifications.go
···
400
400
pull_created,
401
401
pull_commented,
402
402
followed,
403
+
user_mentioned,
403
404
pull_merged,
404
405
issue_closed,
405
406
email_notifications
···
425
426
&prefs.PullCreated,
426
427
&prefs.PullCommented,
427
428
&prefs.Followed,
429
+
&prefs.UserMentioned,
428
430
&prefs.PullMerged,
429
431
&prefs.IssueClosed,
430
432
&prefs.EmailNotifications,
···
446
448
query := `
447
449
INSERT OR REPLACE INTO notification_preferences
448
450
(user_did, repo_starred, issue_created, issue_commented, pull_created,
449
-
pull_commented, followed, pull_merged, issue_closed, email_notifications)
450
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
451
+
pull_commented, followed, user_mentioned, pull_merged, issue_closed,
452
+
email_notifications)
453
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
451
454
`
452
455
453
456
result, err := d.DB.ExecContext(ctx, query,
···
458
461
prefs.PullCreated,
459
462
prefs.PullCommented,
460
463
prefs.Followed,
464
+
prefs.UserMentioned,
461
465
prefs.PullMerged,
462
466
prefs.IssueClosed,
463
467
prefs.EmailNotifications,
+3
-1
appview/models/notifications.go
+3
-1
appview/models/notifications.go
···
87
87
PullCreated bool
88
88
PullCommented bool
89
89
Followed bool
90
+
UserMentioned bool
90
91
PullMerged bool
91
92
IssueClosed bool
92
93
EmailNotifications bool
···
117
118
case NotificationTypeFollowed:
118
119
return prefs.Followed
119
120
case NotificationTypeUserMentioned:
120
-
return true // always notify on mention
121
+
return prefs.UserMentioned
121
122
default:
122
123
return false
123
124
}
···
132
133
PullCreated: true,
133
134
PullCommented: true,
134
135
Followed: true,
136
+
UserMentioned: true,
135
137
PullMerged: true,
136
138
IssueClosed: true,
137
139
EmailNotifications: false,
+14
appview/pages/templates/user/settings/notifications.html
+14
appview/pages/templates/user/settings/notifications.html
···
144
144
<div class="flex items-center justify-between p-2">
145
145
<div class="flex items-center gap-2">
146
146
<div class="flex flex-col gap-1">
147
+
<span class="font-bold">Mentions</span>
148
+
<div class="flex text-sm items-center gap-1 text-gray-500 dark:text-gray-400">
149
+
<span>When someone mentions you.</span>
150
+
</div>
151
+
</div>
152
+
</div>
153
+
<label class="flex items-center gap-2">
154
+
<input type="checkbox" name="mentioned" {{if .Preferences.UserMentioned}}checked{{end}}>
155
+
</label>
156
+
</div>
157
+
158
+
<div class="flex items-center justify-between p-2">
159
+
<div class="flex items-center gap-2">
160
+
<div class="flex flex-col gap-1">
147
161
<span class="font-bold">Email notifications</span>
148
162
<div class="flex text-sm items-center gap-1 text-gray-500 dark:text-gray-400">
149
163
<span>Receive notifications via email in addition to in-app notifications.</span>
+1
appview/settings/settings.go
+1
appview/settings/settings.go
···
120
120
PullCommented: r.FormValue("pull_commented") == "on",
121
121
PullMerged: r.FormValue("pull_merged") == "on",
122
122
Followed: r.FormValue("followed") == "on",
123
+
UserMentioned: r.FormValue("user_mentioned") == "on",
123
124
EmailNotifications: r.FormValue("email_notifications") == "on",
124
125
}
125
126