mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 10:12:26 -05:00
[feature] add paging to AP following / followers endpoints (#2198)
This commit is contained in:
parent
c6fdcd52fa
commit
fc11deeb83
9 changed files with 618 additions and 41 deletions
|
|
@ -23,7 +23,7 @@ import (
|
|||
"net/url"
|
||||
|
||||
"github.com/superseriousbusiness/activity/streams/vocab"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
)
|
||||
|
||||
// Followers obtains the Followers Collection for an actor with the
|
||||
|
|
@ -38,25 +38,19 @@ func (f *federatingDB) Followers(ctx context.Context, actorIRI *url.URL) (follow
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Fetch followers for account from database.
|
||||
follows, err := f.state.DB.GetAccountFollowers(ctx, acct.ID, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Followers: db error getting followers for account id %s: %s", acct.ID, err)
|
||||
}
|
||||
|
||||
// Convert the followers to a slice of account URIs.
|
||||
iris := make([]*url.URL, 0, len(follows))
|
||||
for _, follow := range follows {
|
||||
if follow.Account == nil {
|
||||
// Follow account no longer exists,
|
||||
// for some reason. Skip this one.
|
||||
log.WithContext(ctx).WithField("follow", follow).Warnf("follow missing account %s", follow.AccountID)
|
||||
continue
|
||||
}
|
||||
|
||||
u, err := url.Parse(follow.Account.URI)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, gtserror.Newf("invalid account uri: %v", err)
|
||||
}
|
||||
|
||||
iris = append(iris, u)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,11 +19,10 @@ package federatingdb
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/superseriousbusiness/activity/streams/vocab"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
)
|
||||
|
||||
// Following obtains the Following Collection for an actor with the
|
||||
|
|
@ -38,23 +37,18 @@ func (f *federatingDB) Following(ctx context.Context, actorIRI *url.URL) (follow
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Fetch follows for account from database.
|
||||
follows, err := f.state.DB.GetAccountFollows(ctx, acct.ID, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Following: db error getting following for account id %s: %w", acct.ID, err)
|
||||
return nil, gtserror.Newf("db error getting following for account id %s: %w", acct.ID, err)
|
||||
}
|
||||
|
||||
// Convert the follows to a slice of account URIs.
|
||||
iris := make([]*url.URL, 0, len(follows))
|
||||
for _, follow := range follows {
|
||||
if follow.TargetAccount == nil {
|
||||
// Follow target account no longer exists,
|
||||
// for some reason. Skip this one.
|
||||
log.WithContext(ctx).WithField("follow", follow).Warnf("follow missing target account %s", follow.TargetAccountID)
|
||||
continue
|
||||
}
|
||||
|
||||
u, err := url.Parse(follow.TargetAccount.URI)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, gtserror.Newf("invalid account uri: %v", err)
|
||||
}
|
||||
iris = append(iris, u)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue