+7
appview/db/db.go
+7
appview/db/db.go
···
1113
return err
1114
})
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
+
1123
return &DB{
1124
db,
1125
logger,
+6
-2
appview/db/notifications.go
+6
-2
appview/db/notifications.go
···
394
pull_created,
395
pull_commented,
396
followed,
397
pull_merged,
398
issue_closed,
399
email_notifications
···
419
&prefs.PullCreated,
420
&prefs.PullCommented,
421
&prefs.Followed,
422
&prefs.PullMerged,
423
&prefs.IssueClosed,
424
&prefs.EmailNotifications,
···
440
query := `
441
INSERT OR REPLACE INTO notification_preferences
442
(user_did, repo_starred, issue_created, issue_commented, pull_created,
443
-
pull_commented, followed, pull_merged, issue_closed, email_notifications)
444
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
445
`
446
447
result, err := d.DB.ExecContext(ctx, query,
···
452
prefs.PullCreated,
453
prefs.PullCommented,
454
prefs.Followed,
455
prefs.PullMerged,
456
prefs.IssueClosed,
457
prefs.EmailNotifications,
···
394
pull_created,
395
pull_commented,
396
followed,
397
+
user_mentioned,
398
pull_merged,
399
issue_closed,
400
email_notifications
···
420
&prefs.PullCreated,
421
&prefs.PullCommented,
422
&prefs.Followed,
423
+
&prefs.UserMentioned,
424
&prefs.PullMerged,
425
&prefs.IssueClosed,
426
&prefs.EmailNotifications,
···
442
query := `
443
INSERT OR REPLACE INTO notification_preferences
444
(user_did, repo_starred, issue_created, issue_commented, pull_created,
445
+
pull_commented, followed, user_mentioned, pull_merged, issue_closed,
446
+
email_notifications)
447
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
448
`
449
450
result, err := d.DB.ExecContext(ctx, query,
···
455
prefs.PullCreated,
456
prefs.PullCommented,
457
prefs.Followed,
458
+
prefs.UserMentioned,
459
prefs.PullMerged,
460
prefs.IssueClosed,
461
prefs.EmailNotifications,
+3
-1
appview/models/notifications.go
+3
-1
appview/models/notifications.go
···
87
PullCreated bool
88
PullCommented bool
89
Followed bool
90
PullMerged bool
91
IssueClosed bool
92
EmailNotifications bool
···
117
case NotificationTypeFollowed:
118
return prefs.Followed
119
case NotificationTypeUserMentioned:
120
-
return true // always notify on mention
121
default:
122
return false
123
}
···
132
PullCreated: true,
133
PullCommented: true,
134
Followed: true,
135
PullMerged: true,
136
IssueClosed: true,
137
EmailNotifications: false,
···
87
PullCreated bool
88
PullCommented bool
89
Followed bool
90
+
UserMentioned bool
91
PullMerged bool
92
IssueClosed bool
93
EmailNotifications bool
···
118
case NotificationTypeFollowed:
119
return prefs.Followed
120
case NotificationTypeUserMentioned:
121
+
return prefs.UserMentioned
122
default:
123
return false
124
}
···
133
PullCreated: true,
134
PullCommented: true,
135
Followed: true,
136
+
UserMentioned: true,
137
PullMerged: true,
138
IssueClosed: true,
139
EmailNotifications: false,
+14
appview/pages/templates/user/settings/notifications.html
+14
appview/pages/templates/user/settings/notifications.html
···
144
<div class="flex items-center justify-between p-2">
145
<div class="flex items-center gap-2">
146
<div class="flex flex-col gap-1">
147
<span class="font-bold">Email notifications</span>
148
<div class="flex text-sm items-center gap-1 text-gray-500 dark:text-gray-400">
149
<span>Receive notifications via email in addition to in-app notifications.</span>
···
144
<div class="flex items-center justify-between p-2">
145
<div class="flex items-center gap-2">
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">
161
<span class="font-bold">Email notifications</span>
162
<div class="flex text-sm items-center gap-1 text-gray-500 dark:text-gray-400">
163
<span>Receive notifications via email in addition to in-app notifications.</span>
+1
appview/settings/settings.go
+1
appview/settings/settings.go