diff options
author | 2022-05-02 12:53:46 +0200 | |
---|---|---|
committer | 2022-05-02 11:53:46 +0100 | |
commit | a5852fd7e43bf97ea7def9de20cd6d02d954094d (patch) | |
tree | d72b7fe9bf603786a5533e6b566a8412b2b8f634 /internal/processing/federation/getstatus.go | |
parent | Add logging to the new generic worker package (#516) (diff) | |
download | gotosocial-a5852fd7e43bf97ea7def9de20cd6d02d954094d.tar.xz |
[performance] Speed up some of the slower db queries (#523)
* remove unnecessary LOWER() db calls
* warn during slow db queries
* use bundb built-in exists function
* add db block test
* update account block query
* add domain block db test
* optimize domain block query
* fix implementing wrong test
* exclude most columns when checking block
* go fmt
* remote more unnecessary use of LOWER()
Diffstat (limited to 'internal/processing/federation/getstatus.go')
-rw-r--r-- | internal/processing/federation/getstatus.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/internal/processing/federation/getstatus.go b/internal/processing/federation/getstatus.go index 820f1a19b..2cc37071e 100644 --- a/internal/processing/federation/getstatus.go +++ b/internal/processing/federation/getstatus.go @@ -24,9 +24,7 @@ import ( "net/url" "github.com/superseriousbusiness/activity/streams" - "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtserror" - "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" ) func (p *processor) GetStatus(ctx context.Context, requestedUsername string, requestedStatusID string, requestURL *url.URL) (interface{}, gtserror.WithCode) { @@ -59,14 +57,15 @@ func (p *processor) GetStatus(ctx context.Context, requestedUsername string, req } // get the status out of the database here - s := >smodel.Status{} - if err := p.db.GetWhere(ctx, []db.Where{ - {Key: "id", Value: requestedStatusID, CaseInsensitive: true}, - {Key: "account_id", Value: requestedAccount.ID, CaseInsensitive: true}, - }, s); err != nil { + s, err := p.db.GetStatusByID(ctx, requestedStatusID) + if err != nil { return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting status with id %s and account id %s: %s", requestedStatusID, requestedAccount.ID, err)) } + if s.AccountID != requestedAccount.ID { + return nil, gtserror.NewErrorNotFound(fmt.Errorf("status with id %s does not belong to account with id %s", s.ID, requestedAccount.ID)) + } + visible, err := p.filter.StatusVisible(ctx, s, requestingAccount) if err != nil { return nil, gtserror.NewErrorInternalError(err) |