@@ -48,8 +48,8 @@ func Notifications(ctx *context.Context) {
4848
4949func prepareUserNotificationsData (ctx * context.Context ) {
5050 pageType := ctx .FormString ("type" , ctx .FormString ("q" )) // "q" is the legacy query parameter for "page type"
51- page := min (1 , ctx .FormInt ("page" ))
52- perPage := util .IfZero (ctx .FormInt ("perPage" ), 20 )
51+ page := max (1 , ctx .FormInt ("page" ))
52+ perPage := util .IfZero (ctx .FormInt ("perPage" ), 20 ) // this value is never used or exposed ....
5353 queryStatus := util .Iif (pageType == "read" , activities_model .NotificationStatusRead , activities_model .NotificationStatusUnread )
5454
5555 total , err := db .Count [activities_model.Notification ](ctx , activities_model.FindNotificationOptions {
@@ -64,7 +64,7 @@ func prepareUserNotificationsData(ctx *context.Context) {
6464 // redirect to the last page if request page is more than total pages
6565 pager := context .NewPagination (int (total ), perPage , page , 5 )
6666 if pager .Paginater .Current () < page {
67- ctx .Redirect (fmt .Sprintf ("%s/notifications?q =%s&page=%d" , setting .AppSubURL , url .QueryEscape (ctx . FormString ( "q" ) ), pager .Paginater .Current ()))
67+ ctx .Redirect (fmt .Sprintf ("%s/notifications?type =%s&page=%d" , setting .AppSubURL , url .QueryEscape (pageType ), pager .Paginater .Current ()))
6868 return
6969 }
7070
@@ -136,18 +136,18 @@ func prepareUserNotificationsData(ctx *context.Context) {
136136// NotificationStatusPost is a route for changing the status of a notification
137137func NotificationStatusPost (ctx * context.Context ) {
138138 notificationID := ctx .FormInt64 ("notification_id" )
139- var status activities_model.NotificationStatus
139+ var newStatus activities_model.NotificationStatus
140140 switch ctx .FormString ("notification_action" ) {
141141 case "mark_as_read" :
142- status = activities_model .NotificationStatusRead
142+ newStatus = activities_model .NotificationStatusRead
143143 case "mark_as_unread" :
144- status = activities_model .NotificationStatusUnread
144+ newStatus = activities_model .NotificationStatusUnread
145145 case "pin" :
146- status = activities_model .NotificationStatusPinned
146+ newStatus = activities_model .NotificationStatusPinned
147147 default :
148148 return // ignore user's invalid input
149149 }
150- if _ , err := activities_model .SetNotificationStatus (ctx , notificationID , ctx .Doer , status ); err != nil {
150+ if _ , err := activities_model .SetNotificationStatus (ctx , notificationID , ctx .Doer , newStatus ); err != nil {
151151 ctx .ServerError ("SetNotificationStatus" , err )
152152 return
153153 }
0 commit comments