mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 13:32:25 -05:00
[chore] refactor extractFromCtx a bit (#2646)
This commit is contained in:
parent
a41e8a95bf
commit
d3f35e8eba
8 changed files with 106 additions and 59 deletions
|
|
@ -41,22 +41,25 @@ func (f *federatingDB) Announce(ctx context.Context, announce vocab.ActivityStre
|
|||
l.Debug("entering Announce")
|
||||
}
|
||||
|
||||
receivingAccount, requestingAccount, internal := extractFromCtx(ctx)
|
||||
if internal {
|
||||
activityContext := getActivityContext(ctx)
|
||||
if activityContext.internal {
|
||||
return nil // Already processed.
|
||||
}
|
||||
|
||||
requestingAcct := activityContext.requestingAcct
|
||||
receivingAcct := activityContext.receivingAcct
|
||||
|
||||
// Ensure requestingAccount is among
|
||||
// the Actors doing the Announce.
|
||||
//
|
||||
// We don't support Announce forwards.
|
||||
actorIRIs := ap.GetActorIRIs(announce)
|
||||
if !slices.ContainsFunc(actorIRIs, func(actorIRI *url.URL) bool {
|
||||
return actorIRI.String() == requestingAccount.URI
|
||||
return actorIRI.String() == requestingAcct.URI
|
||||
}) {
|
||||
return gtserror.Newf(
|
||||
"requestingAccount %s was not among Announce Actors",
|
||||
requestingAccount.URI,
|
||||
requestingAcct.URI,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +79,7 @@ func (f *federatingDB) Announce(ctx context.Context, announce vocab.ActivityStre
|
|||
APObjectType: ap.ActivityAnnounce,
|
||||
APActivityType: ap.ActivityCreate,
|
||||
GTSModel: boost,
|
||||
ReceivingAccount: receivingAccount,
|
||||
ReceivingAccount: receivingAcct,
|
||||
})
|
||||
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue