From 4920229a3b6e1d7dde536bc9ff766542b05d935c Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 20 Aug 2021 12:26:56 +0200 Subject: Database updates (#144) * start moving some database stuff around * continue moving db stuff around * more fiddling * more updates * and some more * and yet more * i broke SOMETHING but what, it's a mystery * tidy up * vendor ttlcache * use ttlcache * fix up some tests * rename some stuff * little reminder * some more updates --- internal/processing/account/removeblock.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'internal/processing/account/removeblock.go') diff --git a/internal/processing/account/removeblock.go b/internal/processing/account/removeblock.go index 03b0c6750..7c1f2bc17 100644 --- a/internal/processing/account/removeblock.go +++ b/internal/processing/account/removeblock.go @@ -29,11 +29,9 @@ import ( func (p *processor) BlockRemove(requestingAccount *gtsmodel.Account, targetAccountID string) (*apimodel.Relationship, gtserror.WithCode) { // make sure the target account actually exists in our db - targetAcct := >smodel.Account{} - if err := p.db.GetByID(targetAccountID, targetAcct); err != nil { - if _, ok := err.(db.ErrNoEntries); ok { - return nil, gtserror.NewErrorNotFound(fmt.Errorf("BlockRemove: account %s not found in the db: %s", targetAccountID, err)) - } + targetAccount, err := p.db.GetAccountByID(targetAccountID) + if err != nil { + return nil, gtserror.NewErrorNotFound(fmt.Errorf("BlockCreate: error getting account %s from the db: %s", targetAccountID, err)) } // check if a block exists, and remove it if it does (storing the URI for later) @@ -44,7 +42,7 @@ func (p *processor) BlockRemove(requestingAccount *gtsmodel.Account, targetAccou {Key: "target_account_id", Value: targetAccountID}, }, block); err == nil { block.Account = requestingAccount - block.TargetAccount = targetAcct + block.TargetAccount = targetAccount if err := p.db.DeleteByID(block.ID, >smodel.Block{}); err != nil { return nil, gtserror.NewErrorInternalError(fmt.Errorf("BlockRemove: error removing block from db: %s", err)) } @@ -58,7 +56,7 @@ func (p *processor) BlockRemove(requestingAccount *gtsmodel.Account, targetAccou APActivityType: gtsmodel.ActivityStreamsUndo, GTSModel: block, OriginAccount: requestingAccount, - TargetAccount: targetAcct, + TargetAccount: targetAccount, } } -- cgit v1.2.3