5
5
package activitypub
6
6
7
7
import (
8
+ "fmt"
8
9
"io"
9
10
"net/http"
10
11
"strings"
@@ -15,6 +16,7 @@ import (
15
16
user_model "code.gitea.io/gitea/models/user"
16
17
"code.gitea.io/gitea/modules/activitypub"
17
18
"code.gitea.io/gitea/modules/context"
19
+ "code.gitea.io/gitea/modules/convert"
18
20
"code.gitea.io/gitea/modules/forgefed"
19
21
"code.gitea.io/gitea/modules/log"
20
22
"code.gitea.io/gitea/modules/setting"
@@ -164,31 +166,45 @@ func PersonOutbox(ctx *context.APIContext) {
164
166
165
167
link := setting .AppURL + "api/v1/activitypub/user/" + ctx .ContextUser .Name
166
168
167
- outbox := ap .OrderedCollectionNew (ap .IRI (link + "/outbox" ))
169
+ orderedCollection := ap .OrderedCollectionNew (ap .IRI (link + "/outbox" ))
170
+ orderedCollection .First = ap .IRI (link + "/outbox?page=1" )
171
+
172
+ outbox := ap .OrderedCollectionPageNew (orderedCollection )
173
+ outbox .First = ap .IRI (link + "/outbox?page=1" )
168
174
169
175
feed , err := models .GetFeeds (ctx , models.GetFeedsOptions {
170
- RequestedUser : ctx .ContextUser ,
171
- Actor : ctx .ContextUser ,
172
- IncludePrivate : false ,
173
- IncludeDeleted : false ,
174
- ListOptions : db.ListOptions {Page : 1 , PageSize : 1000000 },
176
+ RequestedUser : ctx .ContextUser ,
177
+ RequestedActionType : models .ActionCreateRepo ,
178
+ Actor : ctx .Doer ,
179
+ IncludePrivate : false ,
180
+ IncludeDeleted : false ,
181
+ ListOptions : utils .GetListOptions (ctx ),
175
182
})
183
+
184
+ // Only specify next if this amount of feed corresponds to the calculated limit.
185
+ if len (feed ) == convert .ToCorrectPageSize (ctx .FormInt ("limit" )) {
186
+ outbox .Next = ap .IRI (fmt .Sprintf ("%s/outbox?page=%d" , link , ctx .FormInt ("page" )+ 1 ))
187
+ }
188
+
189
+ // Only specify previous page when there is one.
190
+ if ctx .FormInt ("page" ) > 1 {
191
+ outbox .Prev = ap .IRI (fmt .Sprintf ("%s/outbox?page=%d" , link , ctx .FormInt ("page" )- 1 ))
192
+ }
193
+
176
194
if err != nil {
177
195
ctx .ServerError ("Couldn't fetch feed" , err )
178
196
return
179
197
}
180
198
181
199
for _ , action := range feed {
182
- if action .OpType == models .ActionCreateRepo {
183
- // Created a repo
184
- object := ap.Note {Type : ap .NoteType , Content : ap .NaturalLanguageValuesNew ()}
185
- _ = object .Content .Set ("en" , ap .Content (action .GetRepoName ()))
186
- create := ap.Create {Type : ap .CreateType , Object : object }
187
- err := outbox .OrderedItems .Append (create )
188
- if err != nil {
189
- ctx .ServerError ("OrderedItems.Append" , err )
190
- return
191
- }
200
+ // Created a repo
201
+ object := ap.Note {Type : ap .NoteType , Content : ap .NaturalLanguageValuesNew ()}
202
+ _ = object .Content .Set ("en" , ap .Content (action .GetRepoName ()))
203
+ create := ap.Create {Type : ap .CreateType , Object : object }
204
+ err := outbox .OrderedItems .Append (create )
205
+ if err != nil {
206
+ ctx .ServerError ("OrderedItems.Append" , err )
207
+ return
192
208
}
193
209
}
194
210
0 commit comments