[chore] Tidy up some of the search logic (#1082)

* start refactoring some of the search + deref logic

* add tests for search api

* rename GetRemoteAccount + GetRemoteStatus

* make search function a bit simpler + clearer

* fix little fucky wucky uwu owo i'm just a little guy

* update faulty switch statements

* update test to use storage struct

* redo switches for clarity

* reduce repeated logic in search tests

* fastfail getstatus by uri

* debug log + trace log better

* add implementation note

* return early if no result for namestring search

* return + check on dereferencing error types

* errors hah what errors

* remove unneeded error type alias, add custom error text during stringification itself

* fix a woops recursion 🙈

Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: kim <grufwub@gmail.com>
This commit is contained in:
tobi 2022-11-29 10:24:55 +01:00 committed by GitHub
commit 97f5453378
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 890 additions and 282 deletions

View file

@ -114,7 +114,7 @@ func (d *deref) dereferenceStatusAncestors(ctx context.Context, username string,
l.Tracef("following remote status ancestors: %s", status.InReplyToURI)
// Fetch the remote status found at this IRI
remoteStatus, _, err := d.GetRemoteStatus(ctx, username, replyIRI, false, false)
remoteStatus, _, err := d.GetStatus(ctx, username, replyIRI, false, false)
if err != nil {
return fmt.Errorf("error fetching remote status %q: %w", status.InReplyToURI, err)
}
@ -276,7 +276,7 @@ stackLoop:
}
// Dereference the remote status and store in the database
_, statusable, err := d.GetRemoteStatus(ctx, username, itemIRI, true, false)
_, statusable, err := d.GetStatus(ctx, username, itemIRI, true, false)
if err != nil {
l.Errorf("error dereferencing remote status %q: %s", itemIRI.String(), err)
continue itemLoop