@@ -13,7 +13,6 @@ import (
13
13
"code.gitea.io/gitea/modules/context"
14
14
"code.gitea.io/gitea/modules/convert"
15
15
"code.gitea.io/gitea/modules/log"
16
- "code.gitea.io/gitea/routers/api/v1/utils"
17
16
)
18
17
19
18
func statusStringToNotificationStatus (status string ) models.NotificationStatus {
@@ -67,27 +66,31 @@ func ListRepoNotifications(ctx *context.APIContext) {
67
66
// in: query
68
67
// description: If true, show notifications marked as read. Default value is false
69
68
// type: string
70
- // required: false
71
69
// - name: status-types
72
70
// in: query
73
71
// description: "Show notifications with the provided status types. Options are: unread, read and/or pinned. Defaults to unread & pinned"
74
72
// type: array
75
73
// collectionFormat: multi
76
74
// items:
77
75
// 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]
79
84
// - name: since
80
85
// in: query
81
86
// description: Only show notifications updated after the given time. This is a timestamp in RFC 3339 format
82
87
// type: string
83
88
// format: date-time
84
- // required: false
85
89
// - name: before
86
90
// in: query
87
91
// description: Only show notifications updated before the given time. This is a timestamp in RFC 3339 format
88
92
// type: string
89
93
// format: date-time
90
- // required: false
91
94
// - name: page
92
95
// in: query
93
96
// description: page number of results to return (1-based)
@@ -99,24 +102,12 @@ func ListRepoNotifications(ctx *context.APIContext) {
99
102
// responses:
100
103
// "200":
101
104
// "$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 () {
106
107
return
107
108
}
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
115
110
116
- if ! ctx .QueryBool ("all" ) {
117
- statuses := ctx .QueryStrings ("status-types" )
118
- opts .Status = statusStringsToNotificationStatuses (statuses , []string {"unread" , "pinned" })
119
- }
120
111
nl , err := models .GetNotifications (opts )
121
112
if err != nil {
122
113
ctx .InternalServerError (err )
@@ -192,7 +183,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
192
183
}
193
184
}
194
185
195
- opts := models.FindNotificationOptions {
186
+ opts := & models.FindNotificationOptions {
196
187
UserID : ctx .User .ID ,
197
188
RepoID : ctx .Repo .Repository .ID ,
198
189
UpdatedBeforeUnix : lastRead ,
0 commit comments