summaryrefslogtreecommitdiff
path: root/internal/db
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db')
-rw-r--r--internal/db/bundb/relationship.go17
-rw-r--r--internal/db/relationship.go2
2 files changed, 15 insertions, 4 deletions
diff --git a/internal/db/bundb/relationship.go b/internal/db/bundb/relationship.go
index 2f93b12ad..f1bdcf52b 100644
--- a/internal/db/bundb/relationship.go
+++ b/internal/db/bundb/relationship.go
@@ -150,9 +150,9 @@ func (r *relationshipDB) GetAccountFollowRequesting(ctx context.Context, account
return r.GetFollowRequestsByIDs(ctx, followReqIDs)
}
-func (r *relationshipDB) GetAccountBlocks(ctx context.Context, accountID string, page *paging.Pager) ([]*gtsmodel.Block, error) {
+func (r *relationshipDB) GetAccountBlocks(ctx context.Context, accountID string, page *paging.Page) ([]*gtsmodel.Block, error) {
// Load block IDs from cache with database loader callback.
- blockIDs, err := r.state.Caches.GTS.BlockIDs().LoadRange(accountID, func() ([]string, error) {
+ blockIDs, err := r.state.Caches.GTS.BlockIDs().Load(accountID, func() ([]string, error) {
var blockIDs []string
// Block IDs not in cache, perform DB query!
@@ -162,11 +162,22 @@ func (r *relationshipDB) GetAccountBlocks(ctx context.Context, accountID string,
}
return blockIDs, nil
- }, page.PageDesc)
+ })
if err != nil {
return nil, err
}
+ // Our cached / selected block IDs are
+ // ALWAYS stored in descending order.
+ // Depending on the paging requested
+ // this may be an unexpected order.
+ if !page.GetOrder().Ascending() {
+ blockIDs = paging.Reverse(blockIDs)
+ }
+
+ // Page the resulting block IDs.
+ blockIDs = page.Page(blockIDs)
+
// Convert these IDs to full block objects.
return r.GetBlocksByIDs(ctx, blockIDs)
}
diff --git a/internal/db/relationship.go b/internal/db/relationship.go
index 50f615ef3..91c98644c 100644
--- a/internal/db/relationship.go
+++ b/internal/db/relationship.go
@@ -174,7 +174,7 @@ type Relationship interface {
CountAccountFollowRequesting(ctx context.Context, accountID string) (int, error)
// GetAccountBlocks returns all blocks originating from the given account, with given optional paging parameters.
- GetAccountBlocks(ctx context.Context, accountID string, paging *paging.Pager) ([]*gtsmodel.Block, error)
+ GetAccountBlocks(ctx context.Context, accountID string, paging *paging.Page) ([]*gtsmodel.Block, error)
// GetNote gets a private note from a source account on a target account, if it exists.
GetNote(ctx context.Context, sourceAccountID string, targetAccountID string) (*gtsmodel.AccountNote, error)