summaryrefslogtreecommitdiff
path: root/internal/api
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-09-20 16:49:46 +0100
committerLibravatar GitHub <noreply@github.com>2023-09-20 16:49:46 +0100
commitfc11deeb83a76a0dbe550842ce6594602a9fb8bc (patch)
treec2d079d548218bda1113308e8ad7a0351308294d /internal/api
parent[chore]: Bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp... (diff)
downloadgotosocial-fc11deeb83a76a0dbe550842ce6594602a9fb8bc.tar.xz
[feature] add paging to AP following / followers endpoints (#2198)
Diffstat (limited to 'internal/api')
-rw-r--r--internal/api/activitypub/users/followers.go13
-rw-r--r--internal/api/activitypub/users/following.go13
2 files changed, 24 insertions, 2 deletions
diff --git a/internal/api/activitypub/users/followers.go b/internal/api/activitypub/users/followers.go
index 07bf5a421..e93ef8d4d 100644
--- a/internal/api/activitypub/users/followers.go
+++ b/internal/api/activitypub/users/followers.go
@@ -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
diff --git a/internal/api/activitypub/users/following.go b/internal/api/activitypub/users/following.go
index 126ef99b2..54fb3b676 100644
--- a/internal/api/activitypub/users/following.go
+++ b/internal/api/activitypub/users/following.go
@@ -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