aboutsummaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2020-10-19 06:05:59 +0000
committerr <r@freesoftwareextremist.com>2020-10-19 06:05:59 +0000
commita23fd4afafe4d7609ae003b3d1e8598969871cb5 (patch)
tree05fc15b90142d4064feae60fd2a18f8a18f592eb /service
parent2ee5c1709d9718474ce277e71d159b2b2e6436c8 (diff)
downloadbloat-a23fd4afafe4d7609ae003b3d1e8598969871cb5.tar.gz
bloat-a23fd4afafe4d7609ae003b3d1e8598969871cb5.zip
Avoid search call for empty query
Diffstat (limited to 'service')
-rw-r--r--service/service.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/service/service.go b/service/service.go
index 8db94f8..447f186 100644
--- a/service/service.go
+++ b/service/service.go
@@ -583,9 +583,14 @@ func (svc *service) ServeUserSearchPage(c *model.Client,
return
}
- results, err := c.Search(ctx, q, "statuses", 20, true, offset, id)
- if err != nil {
- return
+ var results *mastodon.Results
+ if len(q) > 0 {
+ results, err = c.Search(ctx, q, "statuses", 20, true, offset, id)
+ if err != nil {
+ return err
+ }
+ } else {
+ results = &mastodon.Results{}
}
if len(results.Statuses) == 20 {
@@ -643,9 +648,14 @@ func (svc *service) ServeSearchPage(c *model.Client,
var nextLink string
var title = "search"
- results, err := c.Search(ctx, q, qType, 20, true, offset, "")
- if err != nil {
- return
+ var results *mastodon.Results
+ if len(q) > 0 {
+ results, err = c.Search(ctx, q, qType, 20, true, offset, "")
+ if err != nil {
+ return err
+ }
+ } else {
+ results = &mastodon.Results{}
}
if (qType == "accounts" && len(results.Accounts) == 20) ||