summaryrefslogtreecommitdiff
path: root/internal/processing/account
diff options
context:
space:
mode:
Diffstat (limited to 'internal/processing/account')
-rw-r--r--internal/processing/account/export.go2
-rw-r--r--internal/processing/account/lists.go43
2 files changed, 13 insertions, 32 deletions
diff --git a/internal/processing/account/export.go b/internal/processing/account/export.go
index 9954ea225..68cc17b6d 100644
--- a/internal/processing/account/export.go
+++ b/internal/processing/account/export.go
@@ -98,7 +98,7 @@ func (p *Processor) ExportLists(
ctx context.Context,
requester *gtsmodel.Account,
) ([][]string, gtserror.WithCode) {
- lists, err := p.state.DB.GetListsForAccountID(ctx, requester.ID)
+ lists, err := p.state.DB.GetListsByAccountID(ctx, requester.ID)
if err != nil && !errors.Is(err, db.ErrNoEntries) {
err = gtserror.Newf("db error getting lists: %w", err)
return nil, gtserror.NewErrorInternalError(err)
diff --git a/internal/processing/account/lists.go b/internal/processing/account/lists.go
index 1d92bee82..04cf4ca73 100644
--- a/internal/processing/account/lists.go
+++ b/internal/processing/account/lists.go
@@ -30,8 +30,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/log"
)
-var noLists = make([]*apimodel.List, 0)
-
// ListsGet returns all lists owned by requestingAccount, which contain a follow for targetAccountID.
func (p *Processor) ListsGet(ctx context.Context, requestingAccount *gtsmodel.Account, targetAccountID string) ([]*apimodel.List, gtserror.WithCode) {
targetAccount, err := p.state.DB.GetAccountByID(ctx, targetAccountID)
@@ -54,52 +52,35 @@ func (p *Processor) ListsGet(ctx context.Context, requestingAccount *gtsmodel.Ac
// Requester has to follow targetAccount
// for them to be in any of their lists.
follow, err := p.state.DB.GetFollow(
+
// Don't populate follow.
gtscontext.SetBarebones(ctx),
requestingAccount.ID,
targetAccountID,
)
if err != nil && !errors.Is(err, db.ErrNoEntries) {
- return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error: %w", err))
+ err := gtserror.Newf("error getting follow: %w", err)
+ return nil, gtserror.NewErrorInternalError(err)
}
if follow == nil {
- return noLists, nil // by definition we know they're in no lists
- }
-
- listEntries, err := p.state.DB.GetListEntriesForFollowID(
- // Don't populate entries.
- gtscontext.SetBarebones(ctx),
- follow.ID,
- )
- if err != nil && !errors.Is(err, db.ErrNoEntries) {
- return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error: %w", err))
+ return []*apimodel.List{}, nil
}
- count := len(listEntries)
- if count == 0 {
- return noLists, nil
+ // Get all lists that this follow is an entry within.
+ lists, err := p.state.DB.GetListsContainingFollowID(ctx, follow.ID)
+ if err != nil {
+ err := gtserror.Newf("error getting lists for follow: %w", err)
+ return nil, gtserror.NewErrorInternalError(err)
}
- apiLists := make([]*apimodel.List, 0, count)
- for _, listEntry := range listEntries {
- list, err := p.state.DB.GetListByID(
- // Don't populate list.
- gtscontext.SetBarebones(ctx),
- listEntry.ListID,
- )
-
- if err != nil {
- log.Debugf(ctx, "skipping list %s due to error %q", listEntry.ListID, err)
- continue
- }
-
+ apiLists := make([]*apimodel.List, 0, len(lists))
+ for _, list := range lists {
apiList, err := p.converter.ListToAPIList(ctx, list)
if err != nil {
- log.Debugf(ctx, "skipping list %s due to error %q", listEntry.ListID, err)
+ log.Errorf(ctx, "error converting list: %v", err)
continue
}
-
apiLists = append(apiLists, apiList)
}