summaryrefslogtreecommitdiff
path: root/internal/processing/search
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-06-22 20:46:36 +0100
committerLibravatar GitHub <noreply@github.com>2023-06-22 20:46:36 +0100
commit9a22102fa8b1ce47571d5bba71e8f36895d21bf0 (patch)
tree3c2af6db0a3905d31243cd840d1dd50bea59dbb0 /internal/processing/search
parent[docs] Clarify email requirement for OIDC (#1918) (diff)
downloadgotosocial-9a22102fa8b1ce47571d5bba71e8f36895d21bf0.tar.xz
[bugfix/chore] oauth entropy fix + media cleanup tasks rewrite (#1853)
Diffstat (limited to 'internal/processing/search')
-rw-r--r--internal/processing/search/get.go39
-rw-r--r--internal/processing/search/lookup.go4
2 files changed, 11 insertions, 32 deletions
diff --git a/internal/processing/search/get.go b/internal/processing/search/get.go
index 936e8acfa..aaade8908 100644
--- a/internal/processing/search/get.go
+++ b/internal/processing/search/get.go
@@ -26,11 +26,9 @@ import (
"strings"
"codeberg.org/gruf/go-kv"
- "github.com/superseriousbusiness/gotosocial/internal/ap"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
- "github.com/superseriousbusiness/gotosocial/internal/federation/dereferencing"
"github.com/superseriousbusiness/gotosocial/internal/gtscontext"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
@@ -62,7 +60,6 @@ func (p *Processor) Get(
account *gtsmodel.Account,
req *apimodel.SearchRequest,
) (*apimodel.SearchResult, gtserror.WithCode) {
-
var (
maxID = req.MaxID
minID = req.MinID
@@ -127,7 +124,7 @@ func (p *Processor) Get(
// accounts, since this is all namestring search can return.
if includeAccounts(queryType) {
// Copy query to avoid altering original.
- var queryC = query
+ queryC := query
// If query looks vaguely like an email address, ie. it doesn't
// start with '@' but it has '@' in it somewhere, it's probably
@@ -284,12 +281,7 @@ func (p *Processor) accountsByNamestring(
if err != nil {
// Check for semi-expected error types.
// On one of these, we can continue.
- var (
- errNotRetrievable = new(*dereferencing.ErrNotRetrievable) // Item can't be dereferenced.
- errWrongType = new(*ap.ErrWrongType) // Item was dereferenced, but wasn't an account.
- )
-
- if !errors.As(err, errNotRetrievable) && !errors.As(err, errWrongType) {
+ if !gtserror.Unretrievable(err) && !gtserror.WrongType(err) {
err = gtserror.Newf("error looking up %s as account: %w", query, err)
return false, gtserror.NewErrorInternalError(err)
}
@@ -331,11 +323,10 @@ func (p *Processor) accountByUsernameDomain(
if err != nil {
err = gtserror.Newf("error checking domain block: %w", err)
return nil, gtserror.NewErrorInternalError(err)
- }
-
- if blocked {
+ } else if blocked {
// Don't search on blocked domain.
- return nil, dereferencing.NewErrNotRetrievable(err)
+ err = gtserror.New("domain blocked")
+ return nil, gtserror.SetUnretrievable(err)
}
}
@@ -365,7 +356,7 @@ func (p *Processor) accountByUsernameDomain(
}
err = fmt.Errorf("account %s could not be retrieved locally and we cannot resolve", usernameDomain)
- return nil, dereferencing.NewErrNotRetrievable(err)
+ return nil, gtserror.SetUnretrievable(err)
}
// byURI looks for account(s) or a status with the given URI
@@ -419,12 +410,7 @@ func (p *Processor) byURI(
if err != nil {
// Check for semi-expected error types.
// On one of these, we can continue.
- var (
- errNotRetrievable = new(*dereferencing.ErrNotRetrievable) // Item can't be dereferenced.
- errWrongType = new(*ap.ErrWrongType) // Item was dereferenced, but wasn't an account.
- )
-
- if !errors.As(err, errNotRetrievable) && !errors.As(err, errWrongType) {
+ if !gtserror.Unretrievable(err) && !gtserror.WrongType(err) {
err = gtserror.Newf("error looking up %s as account: %w", uri, err)
return false, gtserror.NewErrorInternalError(err)
}
@@ -443,12 +429,7 @@ func (p *Processor) byURI(
if err != nil {
// Check for semi-expected error types.
// On one of these, we can continue.
- var (
- errNotRetrievable = new(*dereferencing.ErrNotRetrievable) // Item can't be dereferenced.
- errWrongType = new(*ap.ErrWrongType) // Item was dereferenced, but wasn't a status.
- )
-
- if !errors.As(err, errNotRetrievable) && !errors.As(err, errWrongType) {
+ if !gtserror.Unretrievable(err) && !gtserror.WrongType(err) {
err = gtserror.Newf("error looking up %s as status: %w", uri, err)
return false, gtserror.NewErrorInternalError(err)
}
@@ -519,7 +500,7 @@ func (p *Processor) accountByURI(
}
err = fmt.Errorf("account %s could not be retrieved locally and we cannot resolve", uriStr)
- return nil, dereferencing.NewErrNotRetrievable(err)
+ return nil, gtserror.SetUnretrievable(err)
}
// statusByURI looks for one status with the given URI.
@@ -575,7 +556,7 @@ func (p *Processor) statusByURI(
}
err = fmt.Errorf("status %s could not be retrieved locally and we cannot resolve", uriStr)
- return nil, dereferencing.NewErrNotRetrievable(err)
+ return nil, gtserror.SetUnretrievable(err)
}
// byText searches in the database for accounts and/or
diff --git a/internal/processing/search/lookup.go b/internal/processing/search/lookup.go
index 0f2a4191b..d50183221 100644
--- a/internal/processing/search/lookup.go
+++ b/internal/processing/search/lookup.go
@@ -23,10 +23,8 @@ import (
"fmt"
"strings"
- errorsv2 "codeberg.org/gruf/go-errors/v2"
"codeberg.org/gruf/go-kv"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
- "github.com/superseriousbusiness/gotosocial/internal/federation/dereferencing"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/log"
@@ -82,7 +80,7 @@ func (p *Processor) Lookup(
false, // never resolve!
)
if err != nil {
- if errorsv2.Assignable(err, (*dereferencing.ErrNotRetrievable)(nil)) {
+ if gtserror.Unretrievable(err) {
// ErrNotRetrievable is fine, just wrap it in
// a 404 to indicate we couldn't find anything.
err := fmt.Errorf("%s not found", query)