From d3f35e8eba602dd963a395b304c778e0a776869d Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sat, 17 Feb 2024 15:20:39 +0100 Subject: [chore] refactor extractFromCtx a bit (#2646) --- internal/federation/federatingdb/reject.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'internal/federation/federatingdb/reject.go') diff --git a/internal/federation/federatingdb/reject.go b/internal/federation/federatingdb/reject.go index 738087d62..929559031 100644 --- a/internal/federation/federatingdb/reject.go +++ b/internal/federation/federatingdb/reject.go @@ -40,11 +40,14 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR l.Debug("entering Reject") } - receivingAccount, requestingAccount, internal := extractFromCtx(ctx) - if internal { + activityContext := getActivityContext(ctx) + if activityContext.internal { return nil // Already processed. } + requestingAcct := activityContext.requestingAcct + receivingAcct := activityContext.receivingAcct + for _, obj := range ap.ExtractObjects(reject) { if obj.IsIRI() { @@ -59,13 +62,13 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR // Make sure the creator of the original follow // is the same as whatever inbox this landed in. - if followReq.AccountID != receivingAccount.ID { + if followReq.AccountID != receivingAcct.ID { return errors.New("Reject: follow account and inbox account were not the same") } // Make sure the target of the original follow // is the same as the account making the request. - if followReq.TargetAccountID != requestingAccount.ID { + if followReq.TargetAccountID != requestingAcct.ID { return errors.New("Reject: follow target account and requesting account were not the same") } @@ -89,13 +92,13 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR // Make sure the creator of the original follow // is the same as whatever inbox this landed in. - if gtsFollow.AccountID != receivingAccount.ID { + if gtsFollow.AccountID != receivingAcct.ID { return errors.New("Reject: follow account and inbox account were not the same") } // Make sure the target of the original follow // is the same as the account making the request. - if gtsFollow.TargetAccountID != requestingAccount.ID { + if gtsFollow.TargetAccountID != requestingAcct.ID { return errors.New("Reject: follow target account and requesting account were not the same") } -- cgit v1.2.3