diff options
author | 2024-04-02 11:42:24 +0200 | |
---|---|---|
committer | 2024-04-02 10:42:24 +0100 | |
commit | f05874be3095d3fb3cefd1a92b3c35fe3ae3bf28 (patch) | |
tree | 52f1616259b51d0a8a94a786278b9c0aa5ab2298 /internal/processing/fedi | |
parent | [feature] Add `enable` command to mirror existing `disable` command; update d... (diff) | |
download | gotosocial-f05874be3095d3fb3cefd1a92b3c35fe3ae3bf28.tar.xz |
[feature] Option to hide followers/following (#2788)
Diffstat (limited to 'internal/processing/fedi')
-rw-r--r-- | internal/processing/fedi/collections.go | 31 | ||||
-rw-r--r-- | internal/processing/fedi/status.go | 1 |
2 files changed, 26 insertions, 6 deletions
diff --git a/internal/processing/fedi/collections.go b/internal/processing/fedi/collections.go index 282180862..0eacf45da 100644 --- a/internal/processing/fedi/collections.go +++ b/internal/processing/fedi/collections.go @@ -140,15 +140,25 @@ func (p *Processor) FollowersGet(ctx context.Context, requestedUser string, page params.ID = collectionID params.Total = total - if page == nil { + switch { + + case receiver.IsInstance() || + *receiver.Settings.HideCollections: + // Instance account (can't follow/be followed), + // or an account that hides followers/following. + // Respect this by just returning totalItems. + obj = ap.NewASOrderedCollection(params) + + case page == nil: // i.e. paging disabled, return collection // that links to first page (i.e. path below). + params.First = new(paging.Page) params.Query = make(url.Values, 1) params.Query.Set("limit", "40") // enables paging obj = ap.NewASOrderedCollection(params) - } else { - // i.e. paging enabled + default: + // i.e. paging enabled // Get the request page of full follower objects with attached accounts. followers, err := p.state.DB.GetAccountFollowers(ctx, receiver.ID, page) if err != nil { @@ -239,15 +249,24 @@ func (p *Processor) FollowingGet(ctx context.Context, requestedUser string, page params.ID = collectionID params.Total = total - if page == nil { + switch { + case receiver.IsInstance() || + *receiver.Settings.HideCollections: + // Instance account (can't follow/be followed), + // or an account that hides followers/following. + // Respect this by just returning totalItems. + obj = ap.NewASOrderedCollection(params) + + case page == nil: // i.e. paging disabled, return collection // that links to first page (i.e. path below). + params.First = new(paging.Page) params.Query = make(url.Values, 1) params.Query.Set("limit", "40") // enables paging obj = ap.NewASOrderedCollection(params) - } else { - // i.e. paging enabled + default: + // i.e. paging enabled // Get the request page of full follower objects with attached accounts. follows, err := p.state.DB.GetAccountFollows(ctx, receiver.ID, page) if err != nil { diff --git a/internal/processing/fedi/status.go b/internal/processing/fedi/status.go index 2849d08a4..29c6fe069 100644 --- a/internal/processing/fedi/status.go +++ b/internal/processing/fedi/status.go @@ -156,6 +156,7 @@ func (p *Processor) StatusRepliesGet( if page == nil { // i.e. paging disabled, return collection // that links to first page (i.e. path below). + params.First = new(paging.Page) params.Query = make(url.Values, 1) params.Query.Set("limit", "20") // enables paging obj = ap.NewASOrderedCollection(params) |