[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

@ -53,17 +53,20 @@ func (f *federatingDB) Update(ctx context.Context, asType vocab.Type) error {
l.Debug("entering Update")
}
receivingAccount, requestingAccount, internal := extractFromCtx(ctx)
if internal {
activityContext := getActivityContext(ctx)
if activityContext.internal {
return nil // Already processed.
}
requestingAcct := activityContext.requestingAcct
receivingAcct := activityContext.receivingAcct
if accountable, ok := ap.ToAccountable(asType); ok {
return f.updateAccountable(ctx, receivingAccount, requestingAccount, accountable)
return f.updateAccountable(ctx, receivingAcct, requestingAcct, accountable)
}
if statusable, ok := ap.ToStatusable(asType); ok {
return f.updateStatusable(ctx, receivingAccount, requestingAccount, statusable)
return f.updateStatusable(ctx, receivingAcct, requestingAcct, statusable)
}
return nil