[feature] add paging to AP following / followers endpoints (#2198)

This commit is contained in:
kim 2023-09-20 16:49:46 +01:00 committed by GitHub
commit fc11deeb83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 618 additions and 41 deletions

View file

@ -26,6 +26,7 @@ import (
"github.com/gin-gonic/gin"
apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/paging"
)
// FollowersGETHandler returns a collection of URIs for followers of the target user, formatted so that other AP servers can understand it.
@ -51,7 +52,17 @@ func (m *Module) FollowersGETHandler(c *gin.Context) {
return
}
resp, errWithCode := m.processor.Fedi().FollowersGet(c.Request.Context(), requestedUsername)
page, errWithCode := paging.ParseIDPage(c,
1, // min limit
80, // max limit
0, // default = disabled
)
if errWithCode != nil {
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
return
}
resp, errWithCode := m.processor.Fedi().FollowersGet(c.Request.Context(), requestedUsername, page)
if errWithCode != nil {
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
return

View file

@ -26,6 +26,7 @@ import (
"github.com/gin-gonic/gin"
apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/paging"
)
// FollowingGETHandler returns a collection of URIs for accounts that the target user follows, formatted so that other AP servers can understand it.
@ -51,7 +52,17 @@ func (m *Module) FollowingGETHandler(c *gin.Context) {
return
}
resp, errWithCode := m.processor.Fedi().FollowingGet(c.Request.Context(), requestedUsername)
page, errWithCode := paging.ParseIDPage(c,
1, // min limit
80, // max limit
0, // default = disabled
)
if errWithCode != nil {
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
return
}
resp, errWithCode := m.processor.Fedi().FollowingGet(c.Request.Context(), requestedUsername, page)
if errWithCode != nil {
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
return