summaryrefslogtreecommitdiff
path: root/internal/processing/workers
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-06-12 14:23:10 +0200
committerLibravatar GitHub <noreply@github.com>2024-06-12 13:23:10 +0100
commit20877c147484d2ce7d8cd0513ef8c1bc07570fd9 (patch)
tree7c130db5765048ba02c23d35a2c9c0bd56232261 /internal/processing/workers
parent[chore] Upgrade wasm-sqlite to v0.16.2 (#2997) (diff)
downloadgotosocial-20877c147484d2ce7d8cd0513ef8c1bc07570fd9.tar.xz
[bugfix] Ensure side effects handled for local unlocked follows (#2998)
Diffstat (limited to 'internal/processing/workers')
-rw-r--r--internal/processing/workers/fromclientapi.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/processing/workers/fromclientapi.go b/internal/processing/workers/fromclientapi.go
index 89b8f546f..d5d4265e1 100644
--- a/internal/processing/workers/fromclientapi.go
+++ b/internal/processing/workers/fromclientapi.go
@@ -305,6 +305,30 @@ func (p *clientAPI) CreateFollowReq(ctx context.Context, cMsg *messages.FromClie
return gtserror.Newf("%T not parseable as *gtsmodel.FollowRequest", cMsg.GTSModel)
}
+ // If target is a local, unlocked account,
+ // we can skip side effects for the follow
+ // request and accept the follow immediately.
+ if cMsg.Target.IsLocal() && !*cMsg.Target.Locked {
+ // Accept the FR first to get the Follow.
+ follow, err := p.state.DB.AcceptFollowRequest(
+ ctx,
+ cMsg.Origin.ID,
+ cMsg.Target.ID,
+ )
+ if err != nil {
+ return gtserror.Newf("db error accepting follow req: %w", err)
+ }
+
+ // Use AcceptFollow to do side effects.
+ return p.AcceptFollow(ctx, &messages.FromClientAPI{
+ APObjectType: ap.ActivityFollow,
+ APActivityType: ap.ActivityAccept,
+ GTSModel: follow,
+ Origin: cMsg.Origin,
+ Target: cMsg.Target,
+ })
+ }
+
// Update stats for the target account.
if err := p.utils.incrementFollowRequestsCount(ctx, cMsg.Target); err != nil {
log.Errorf(ctx, "error updating account stats: %v", err)