summaryrefslogtreecommitdiff
path: root/internal/federation/federatingdb/accept.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-07-27 10:45:22 +0200
committerLibravatar GitHub <noreply@github.com>2021-07-27 10:45:22 +0200
commit2c2dbe318e2d01f4d7dbbade3970684e4f0b9f6b (patch)
tree0565cb6e2ce8a3f7f96fb2260fbdc0b7511abd87 /internal/federation/federatingdb/accept.go
parentdoc updates (#117) (diff)
downloadgotosocial-2c2dbe318e2d01f4d7dbbade3970684e4f0b9f6b.tar.xz
federating db updates (#118)
Diffstat (limited to 'internal/federation/federatingdb/accept.go')
-rw-r--r--internal/federation/federatingdb/accept.go30
1 files changed, 16 insertions, 14 deletions
diff --git a/internal/federation/federatingdb/accept.go b/internal/federation/federatingdb/accept.go
index 78cff4094..4d11ea62a 100644
--- a/internal/federation/federatingdb/accept.go
+++ b/internal/federation/federatingdb/accept.go
@@ -31,25 +31,27 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
}
l.Debugf("received ACCEPT asType %s", string(b))
- fromFederatorChanI := ctx.Value(util.APFromFederatorChanKey)
- if fromFederatorChanI == nil {
- l.Error("ACCEPT: from federator channel wasn't set on context")
+ targetAcctI := ctx.Value(util.APAccount)
+ if targetAcctI == nil {
+ // If the target account wasn't set on the context, that means this request didn't pass through the
+ // API, but came from inside GtS as the result of another activity on this instance. That being so,
+ // we can safely just ignore this activity, since we know we've already processed it elsewhere.
return nil
}
- fromFederatorChan, ok := fromFederatorChanI.(chan gtsmodel.FromFederator)
+ targetAcct, ok := targetAcctI.(*gtsmodel.Account)
if !ok {
- l.Error("ACCEPT: from federator channel was set on context but couldn't be parsed")
+ l.Error("ACCEPT: target account was set on context but couldn't be parsed")
return nil
}
- inboxAcctI := ctx.Value(util.APAccount)
- if inboxAcctI == nil {
- l.Error("ACCEPT: inbox account wasn't set on context")
+ fromFederatorChanI := ctx.Value(util.APFromFederatorChanKey)
+ if fromFederatorChanI == nil {
+ l.Error("ACCEPT: from federator channel wasn't set on context")
return nil
}
- inboxAcct, ok := inboxAcctI.(*gtsmodel.Account)
+ fromFederatorChan, ok := fromFederatorChanI.(chan gtsmodel.FromFederator)
if !ok {
- l.Error("ACCEPT: inbox account was set on context but couldn't be parsed")
+ l.Error("ACCEPT: from federator channel was set on context but couldn't be parsed")
return nil
}
@@ -71,7 +73,7 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
}
// make sure the addressee of the original follow is the same as whatever inbox this landed in
- if gtsFollowRequest.AccountID != inboxAcct.ID {
+ if gtsFollowRequest.AccountID != targetAcct.ID {
return errors.New("ACCEPT: follow object account and inbox account were not the same")
}
follow, err := f.db.AcceptFollowRequest(gtsFollowRequest.AccountID, gtsFollowRequest.TargetAccountID)
@@ -83,7 +85,7 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
APObjectType: gtsmodel.ActivityStreamsFollow,
APActivityType: gtsmodel.ActivityStreamsAccept,
GTSModel: follow,
- ReceivingAccount: inboxAcct,
+ ReceivingAccount: targetAcct,
}
return nil
@@ -108,7 +110,7 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
return fmt.Errorf("ACCEPT: error converting asfollow to gtsfollow: %s", err)
}
// make sure the addressee of the original follow is the same as whatever inbox this landed in
- if gtsFollow.AccountID != inboxAcct.ID {
+ if gtsFollow.AccountID != targetAcct.ID {
return errors.New("ACCEPT: follow object account and inbox account were not the same")
}
follow, err := f.db.AcceptFollowRequest(gtsFollow.AccountID, gtsFollow.TargetAccountID)
@@ -120,7 +122,7 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
APObjectType: gtsmodel.ActivityStreamsFollow,
APActivityType: gtsmodel.ActivityStreamsAccept,
GTSModel: follow,
- ReceivingAccount: inboxAcct,
+ ReceivingAccount: targetAcct,
}
return nil