[chore] refactor extractFromCtx a bit (#2646)

This commit is contained in:
tobi 2024-02-17 15:20:39 +01:00 committed by GitHub
commit d3f35e8eba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 106 additions and 59 deletions

View file

@ -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")
}