diff options
author | 2021-07-11 16:22:21 +0200 | |
---|---|---|
committer | 2021-07-11 16:22:21 +0200 | |
commit | 846057f0d696fded87d105dec1245e9ba32763ce (patch) | |
tree | 9a4914c07bcf189a3eea0a2c091567c56cdf4963 /internal/federation/federatingprotocol.go | |
parent | favourites GET implementation (#95) (diff) | |
download | gotosocial-846057f0d696fded87d105dec1245e9ba32763ce.tar.xz |
Block/unblock (#96)
* remote + local block logic, incl. federation
* improve blocking stuff
* fiddle with display of blocked profiles
* go fmt
Diffstat (limited to 'internal/federation/federatingprotocol.go')
-rw-r--r-- | internal/federation/federatingprotocol.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/internal/federation/federatingprotocol.go b/internal/federation/federatingprotocol.go index c0943a328..1acdb6cb1 100644 --- a/internal/federation/federatingprotocol.go +++ b/internal/federation/federatingprotocol.go @@ -243,8 +243,8 @@ func (f *federator) Blocked(ctx context.Context, actorIRIs []*url.URL) (bool, er return true, nil } - a := >smodel.Account{} - if err := f.db.GetWhere([]db.Where{{Key: "uri", Value: uri.String()}}, a); err != nil { + requestingAccount := >smodel.Account{} + if err := f.db.GetWhere([]db.Where{{Key: "uri", Value: uri.String()}}, requestingAccount); err != nil { _, ok := err.(db.ErrNoEntries) if ok { // we don't have an entry for this account so it's not blocked @@ -253,11 +253,13 @@ func (f *federator) Blocked(ctx context.Context, actorIRIs []*url.URL) (bool, er } return false, fmt.Errorf("error getting account with uri %s: %s", uri.String(), err) } - blocked, err := f.db.Blocked(requestedAccount.ID, a.ID) - if err != nil { - return false, fmt.Errorf("error checking account blocks: %s", err) - } - if blocked { + + // check if requested account blocks requesting account + if err := f.db.GetWhere([]db.Where{ + {Key: "account_id", Value: requestedAccount.ID}, + {Key: "target_account_id", Value: requestingAccount.ID}, + }, >smodel.Block{}); err == nil { + // a block exists return true, nil } } |