Monorepo for Tangled tangled.org

appview: add `user_mentioned` notification preference option

Signed-off-by: Seongmin Lee <git@boltless.me>

boltless.me 81d713d1 a29eb256

verified
Changed files
+31 -3
appview
db
models
pages
templates
user
settings
+7
appview/db/db.go
··· 1121 return err 1122 }) 1123 1124 return &DB{ 1125 db, 1126 logger,
··· 1121 return err 1122 }) 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 + 1131 return &DB{ 1132 db, 1133 logger,
+6 -2
appview/db/notifications.go
··· 400 pull_created, 401 pull_commented, 402 followed, 403 pull_merged, 404 issue_closed, 405 email_notifications ··· 425 &prefs.PullCreated, 426 &prefs.PullCommented, 427 &prefs.Followed, 428 &prefs.PullMerged, 429 &prefs.IssueClosed, 430 &prefs.EmailNotifications, ··· 446 query := ` 447 INSERT OR REPLACE INTO notification_preferences 448 (user_did, repo_starred, issue_created, issue_commented, pull_created, 449 - pull_commented, followed, pull_merged, issue_closed, email_notifications) 450 - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 451 ` 452 453 result, err := d.DB.ExecContext(ctx, query, ··· 458 prefs.PullCreated, 459 prefs.PullCommented, 460 prefs.Followed, 461 prefs.PullMerged, 462 prefs.IssueClosed, 463 prefs.EmailNotifications,
··· 400 pull_created, 401 pull_commented, 402 followed, 403 + user_mentioned, 404 pull_merged, 405 issue_closed, 406 email_notifications ··· 426 &prefs.PullCreated, 427 &prefs.PullCommented, 428 &prefs.Followed, 429 + &prefs.UserMentioned, 430 &prefs.PullMerged, 431 &prefs.IssueClosed, 432 &prefs.EmailNotifications, ··· 448 query := ` 449 INSERT OR REPLACE INTO notification_preferences 450 (user_did, repo_starred, issue_created, issue_commented, pull_created, 451 + pull_commented, followed, user_mentioned, pull_merged, issue_closed, 452 + email_notifications) 453 + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 454 ` 455 456 result, err := d.DB.ExecContext(ctx, query, ··· 461 prefs.PullCreated, 462 prefs.PullCommented, 463 prefs.Followed, 464 + prefs.UserMentioned, 465 prefs.PullMerged, 466 prefs.IssueClosed, 467 prefs.EmailNotifications,
+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
··· 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
··· 120 PullCommented: r.FormValue("pull_commented") == "on", 121 PullMerged: r.FormValue("pull_merged") == "on", 122 Followed: r.FormValue("followed") == "on", 123 EmailNotifications: r.FormValue("email_notifications") == "on", 124 } 125
··· 120 PullCommented: r.FormValue("pull_commented") == "on", 121 PullMerged: r.FormValue("pull_merged") == "on", 122 Followed: r.FormValue("followed") == "on", 123 + UserMentioned: r.FormValue("user_mentioned") == "on", 124 EmailNotifications: r.FormValue("email_notifications") == "on", 125 } 126