mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 07:42:24 -06:00
[bugfix/chore] oauth entropy fix + media cleanup tasks rewrite (#1853)
This commit is contained in:
parent
c4cf6326d8
commit
9a22102fa8
38 changed files with 2076 additions and 1090 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue