mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
Block/unblock (#96)
* remote + local block logic, incl. federation * improve blocking stuff * fiddle with display of blocked profiles * go fmt
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user