Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).

appview: add `user_mentioned` notification preference option

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

authored by boltless.me and committed by

Tangled 9ac20f5c 10ad3506

+31 -3
+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
··· 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 ··· 426 425 &prefs.PullCreated, 427 426 &prefs.PullCommented, 428 427 &prefs.Followed, 428 + &prefs.UserMentioned, 429 429 &prefs.PullMerged, 430 430 &prefs.IssueClosed, 431 431 &prefs.EmailNotifications, ··· 448 446 query := ` 449 447 INSERT OR REPLACE INTO notification_preferences 450 448 (user_did, repo_starred, issue_created, issue_commented, pull_created, 451 - pull_commented, followed, pull_merged, issue_closed, email_notifications) 452 - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 449 + pull_commented, followed, user_mentioned, pull_merged, issue_closed, 450 + email_notifications) 451 + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 453 452 ` 454 453 455 454 result, err := d.DB.ExecContext(ctx, query, ··· 461 458 prefs.PullCreated, 462 459 prefs.PullCommented, 463 460 prefs.Followed, 461 + prefs.UserMentioned, 464 462 prefs.PullMerged, 465 463 prefs.IssueClosed, 466 464 prefs.EmailNotifications,
+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 ··· 118 117 case NotificationTypeFollowed: 119 118 return prefs.Followed 120 119 case NotificationTypeUserMentioned: 121 - return true // always notify on mention 120 + return prefs.UserMentioned 122 121 default: 123 122 return false 124 123 } ··· 133 132 PullCreated: true, 134 133 PullCommented: true, 135 134 Followed: true, 135 + UserMentioned: true, 136 136 PullMerged: true, 137 137 IssueClosed: true, 138 138 EmailNotifications: false,
+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
··· 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