summaryrefslogtreecommitdiff
path: root/internal/processing/report/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/report/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/report/get.go')
-rw-r--r--internal/processing/report/get.go26
1 files changed, 10 insertions, 16 deletions
diff --git a/internal/processing/report/get.go b/internal/processing/report/get.go
index bfe7dedf0..f39648832 100644
--- a/internal/processing/report/get.go
+++ b/internal/processing/report/get.go
@@ -19,6 +19,7 @@ package report
import (
"context"
+ "errors"
"fmt"
"strconv"
@@ -64,31 +65,24 @@ func (p *Processor) GetMultiple(
limit int,
) (*apimodel.PageableResponse, gtserror.WithCode) {
reports, err := p.state.DB.GetReports(ctx, resolved, account.ID, targetAccountID, maxID, sinceID, minID, limit)
- if err != nil {
- if err == db.ErrNoEntries {
- return util.EmptyPageableResponse(), nil
- }
+ if err != nil && !errors.Is(err, db.ErrNoEntries) {
return nil, gtserror.NewErrorInternalError(err)
}
count := len(reports)
+ if count == 0 {
+ return util.EmptyPageableResponse(), nil
+ }
+
items := make([]interface{}, 0, count)
- nextMaxIDValue := ""
- prevMinIDValue := ""
- for i, r := range reports {
+ nextMaxIDValue := reports[count-1].ID
+ prevMinIDValue := reports[0].ID
+
+ for _, r := range reports {
item, err := p.tc.ReportToAPIReport(ctx, r)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error converting report to api: %s", err))
}
-
- if i == count-1 {
- nextMaxIDValue = item.ID
- }
-
- if i == 0 {
- prevMinIDValue = item.ID
- }
-
items = append(items, item)
}