@@ -13,7 +13,6 @@ import (
1313 "code.gitea.io/gitea/modules/context"
1414 "code.gitea.io/gitea/modules/convert"
1515 "code.gitea.io/gitea/modules/log"
16- "code.gitea.io/gitea/routers/api/v1/utils"
1716)
1817
1918func statusStringToNotificationStatus (status string ) models.NotificationStatus {
@@ -67,27 +66,31 @@ func ListRepoNotifications(ctx *context.APIContext) {
6766 // in: query
6867 // description: If true, show notifications marked as read. Default value is false
6968 // type: string
70- // required: false
7169 // - name: status-types
7270 // in: query
7371 // description: "Show notifications with the provided status types. Options are: unread, read and/or pinned. Defaults to unread & pinned"
7472 // type: array
7573 // collectionFormat: multi
7674 // items:
7775 // type: string
78- // required: false
76+ // - name: subject-type
77+ // in: query
78+ // description: "filter notifications by subject type"
79+ // type: array
80+ // collectionFormat: multi
81+ // items:
82+ // type: string
83+ // enum: [issue,pull,commit,repository]
7984 // - name: since
8085 // in: query
8186 // description: Only show notifications updated after the given time. This is a timestamp in RFC 3339 format
8287 // type: string
8388 // format: date-time
84- // required: false
8589 // - name: before
8690 // in: query
8791 // description: Only show notifications updated before the given time. This is a timestamp in RFC 3339 format
8892 // type: string
8993 // format: date-time
90- // required: false
9194 // - name: page
9295 // in: query
9396 // description: page number of results to return (1-based)
@@ -99,24 +102,12 @@ func ListRepoNotifications(ctx *context.APIContext) {
99102 // responses:
100103 // "200":
101104 // "$ref": "#/responses/NotificationThreadList"
102-
103- before , since , err := utils .GetQueryBeforeSince (ctx )
104- if err != nil {
105- ctx .Error (http .StatusUnprocessableEntity , "GetQueryBeforeSince" , err )
105+ opts := getFindNotificationOptions (ctx )
106+ if ctx .Written () {
106107 return
107108 }
108- opts := models.FindNotificationOptions {
109- ListOptions : utils .GetListOptions (ctx ),
110- UserID : ctx .User .ID ,
111- RepoID : ctx .Repo .Repository .ID ,
112- UpdatedBeforeUnix : before ,
113- UpdatedAfterUnix : since ,
114- }
109+ opts .RepoID = ctx .Repo .Repository .ID
115110
116- if ! ctx .QueryBool ("all" ) {
117- statuses := ctx .QueryStrings ("status-types" )
118- opts .Status = statusStringsToNotificationStatuses (statuses , []string {"unread" , "pinned" })
119- }
120111 nl , err := models .GetNotifications (opts )
121112 if err != nil {
122113 ctx .InternalServerError (err )
@@ -192,7 +183,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
192183 }
193184 }
194185
195- opts := models.FindNotificationOptions {
186+ opts := & models.FindNotificationOptions {
196187 UserID : ctx .User .ID ,
197188 RepoID : ctx .Repo .Repository .ID ,
198189 UpdatedBeforeUnix : lastRead ,
0 commit comments