summaryrefslogtreecommitdiff
path: root/internal/processing/list/get.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-07-18 09:43:17 +0100
committerLibravatar GitHub <noreply@github.com>2023-07-18 09:43:17 +0100
commitf4319740ab02d680961781861335285f618f5f48 (patch)
tree133595a10ec93cce9da269a4fa671c226bab7298 /internal/processing/list/get.go
parent[bugfix] Add missing `continue` statement in `prepareXBetweenIDs` (#1996) (diff)
downloadgotosocial-f4319740ab02d680961781861335285f618f5f48.tar.xz
[bugfix] more robust list timeline invalidation (#1995)v0.10.0-rc3
Diffstat (limited to 'internal/processing/list/get.go')
-rw-r--r--internal/processing/list/get.go38
1 files changed, 20 insertions, 18 deletions
diff --git a/internal/processing/list/get.go b/internal/processing/list/get.go
index 3f124fe7c..0fc14f934 100644
--- a/internal/processing/list/get.go
+++ b/internal/processing/list/get.go
@@ -87,7 +87,14 @@ func (p *Processor) GetListAccounts(
limit int,
) (*apimodel.PageableResponse, gtserror.WithCode) {
// Ensure list exists + is owned by requesting account.
- if _, errWithCode := p.getList(ctx, account.ID, listID); errWithCode != nil {
+ _, errWithCode := p.getList(
+ // Use barebones ctx; no embedded
+ // structs necessary for this call.
+ gtscontext.SetBarebones(ctx),
+ account.ID,
+ listID,
+ )
+ if errWithCode != nil {
return nil, errWithCode
}
@@ -106,9 +113,12 @@ func (p *Processor) GetListAccounts(
}
var (
- items = make([]interface{}, count)
- nextMaxIDValue string
- prevMinIDValue string
+ items = make([]interface{}, 0, count)
+
+ // Set next + prev values before filtering and API
+ // converting, so caller can still page properly.
+ nextMaxIDValue = listEntries[count-1].ID
+ prevMinIDValue = listEntries[0].ID
)
// For each list entry, we want the account it points to.
@@ -117,37 +127,29 @@ func (p *Processor) GetListAccounts(
// from that follow.
//
// We do paging not by account ID, but by list entry ID.
- for i, listEntry := range listEntries {
- if i == count-1 {
- nextMaxIDValue = listEntry.ID
- }
-
- if i == 0 {
- prevMinIDValue = listEntry.ID
- }
-
+ for _, listEntry := range listEntries {
if err := p.state.DB.PopulateListEntry(ctx, listEntry); err != nil {
- log.Debugf(ctx, "skipping list entry because of error populating it: %q", err)
+ log.Errorf(ctx, "error populating list entry: %v", err)
continue
}
if err := p.state.DB.PopulateFollow(ctx, listEntry.Follow); err != nil {
- log.Debugf(ctx, "skipping list entry because of error populating follow: %q", err)
+ log.Errorf(ctx, "error populating follow: %v", err)
continue
}
apiAccount, err := p.tc.AccountToAPIAccountPublic(ctx, listEntry.Follow.TargetAccount)
if err != nil {
- log.Debugf(ctx, "skipping list entry because of error converting follow target account: %q", err)
+ log.Errorf(ctx, "error converting to public api account: %v", err)
continue
}
- items[i] = apiAccount
+ items = append(items, apiAccount)
}
return util.PackagePageableResponse(util.PageableResponseParams{
Items: items,
- Path: "api/v1/lists/" + listID + "/accounts",
+ Path: "/api/v1/lists/" + listID + "/accounts",
NextMaxIDValue: nextMaxIDValue,
PrevMinIDValue: prevMinIDValue,
Limit: limit,