summaryrefslogtreecommitdiff
path: root/internal/processing
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-07-08 16:43:12 +0200
committerLibravatar GitHub <noreply@github.com>2023-07-08 16:43:12 +0200
commitf40bb02f31ca72f1528cf40291e86024509e34d6 (patch)
tree9f68132057fc882a0b733ce037ea46bec0a3627b /internal/processing
parent[docs] Clarify how to add a page (#1959) (diff)
downloadgotosocial-f40bb02f31ca72f1528cf40291e86024509e34d6.tar.xz
[bugfix] Delete mutual follow (requests) when receiving block from remote (#1960)
* [bugfix] Delete mutual follow (requests) on block * fix test
Diffstat (limited to 'internal/processing')
-rw-r--r--internal/processing/fromfederator.go52
1 files changed, 46 insertions, 6 deletions
diff --git a/internal/processing/fromfederator.go b/internal/processing/fromfederator.go
index 335b1a102..7152393db 100644
--- a/internal/processing/fromfederator.go
+++ b/internal/processing/fromfederator.go
@@ -352,18 +352,58 @@ func (p *Processor) processCreateAnnounceFromFederator(ctx context.Context, fede
func (p *Processor) processCreateBlockFromFederator(ctx context.Context, federatorMsg messages.FromFederator) error {
block, ok := federatorMsg.GTSModel.(*gtsmodel.Block)
if !ok {
- return errors.New("block was not parseable as *gtsmodel.Block")
+ return gtserror.New("block was not parseable as *gtsmodel.Block")
}
- // remove any of the blocking account's statuses from the blocked account's timeline, and vice versa
+ // Remove each account's posts from the other's timelines.
+ //
+ // First home timelines.
if err := p.state.Timelines.Home.WipeItemsFromAccountID(ctx, block.AccountID, block.TargetAccountID); err != nil {
- return err
+ return gtserror.Newf("%w", err)
}
+
if err := p.state.Timelines.Home.WipeItemsFromAccountID(ctx, block.TargetAccountID, block.AccountID); err != nil {
- return err
+ return gtserror.Newf("%w", err)
+ }
+
+ // Now list timelines.
+ if err := p.state.Timelines.List.WipeItemsFromAccountID(ctx, block.AccountID, block.TargetAccountID); err != nil {
+ return gtserror.Newf("%w", err)
+ }
+
+ if err := p.state.Timelines.List.WipeItemsFromAccountID(ctx, block.TargetAccountID, block.AccountID); err != nil {
+ return gtserror.Newf("%w", err)
+ }
+
+ // Remove any follows that existed between blocker + blockee.
+ if err := p.state.DB.DeleteFollowRequest(ctx, block.AccountID, block.TargetAccountID); err != nil {
+ return gtserror.Newf(
+ "db error deleting follow from %s targeting %s: %w",
+ block.AccountID, block.TargetAccountID, err,
+ )
+ }
+
+ if err := p.state.DB.DeleteFollowRequest(ctx, block.TargetAccountID, block.AccountID); err != nil {
+ return gtserror.Newf(
+ "db error deleting follow from %s targeting %s: %w",
+ block.TargetAccountID, block.AccountID, err,
+ )
+ }
+
+ // Remove any follow requests that existed between blocker + blockee.
+ if err := p.state.DB.DeleteFollowRequest(ctx, block.AccountID, block.TargetAccountID); err != nil {
+ return gtserror.Newf(
+ "db error deleting follow request from %s targeting %s: %w",
+ block.AccountID, block.TargetAccountID, err,
+ )
+ }
+
+ if err := p.state.DB.DeleteFollowRequest(ctx, block.TargetAccountID, block.AccountID); err != nil {
+ return gtserror.Newf(
+ "db error deleting follow request from %s targeting %s: %w",
+ block.TargetAccountID, block.AccountID, err,
+ )
}
- // TODO: same with notifications
- // TODO: same with bookmarks
return nil
}