+7
appview/db/db.go
+7
appview/db/db.go
···
1113
1113
return err
1114
1114
})
1115
1115
1116
+
runMigration(conn, logger, "add-usermentioned-preference", func(tx *sql.Tx) error {
1117
+
_, err := tx.Exec(`
1118
+
alter table notification_preferences add column user_mentioned integer not null default 1;
1119
+
`)
1120
+
return err
1121
+
})
1122
+
1116
1123
return &DB{
1117
1124
db,
1118
1125
logger,
+6
-2
appview/db/notifications.go
+6
-2
appview/db/notifications.go
···
394
394
pull_created,
395
395
pull_commented,
396
396
followed,
397
+
user_mentioned,
397
398
pull_merged,
398
399
issue_closed,
399
400
email_notifications
···
419
420
&prefs.PullCreated,
420
421
&prefs.PullCommented,
421
422
&prefs.Followed,
423
+
&prefs.UserMentioned,
422
424
&prefs.PullMerged,
423
425
&prefs.IssueClosed,
424
426
&prefs.EmailNotifications,
···
440
442
query := `
441
443
INSERT OR REPLACE INTO notification_preferences
442
444
(user_did, repo_starred, issue_created, issue_commented, pull_created,
443
-
pull_commented, followed, pull_merged, issue_closed, email_notifications)
444
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
445
+
pull_commented, followed, user_mentioned, pull_merged, issue_closed,
446
+
email_notifications)
447
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
445
448
`
446
449
447
450
result, err := d.DB.ExecContext(ctx, query,
···
452
455
prefs.PullCreated,
453
456
prefs.PullCommented,
454
457
prefs.Followed,
458
+
prefs.UserMentioned,
455
459
prefs.PullMerged,
456
460
prefs.IssueClosed,
457
461
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