mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-02-28 10:48:50 +01:00
update to latest activity
This commit is contained in:
parent
301e822abf
commit
fee12158c4
4 changed files with 90 additions and 46 deletions
2
go.mod
2
go.mod
|
@ -68,7 +68,7 @@ require (
|
|||
github.com/spf13/cobra v1.8.1
|
||||
github.com/spf13/viper v1.19.0
|
||||
github.com/stretchr/testify v1.10.0
|
||||
github.com/superseriousbusiness/activity v1.9.0-gts.0.20250121090817-0ef92d24eba1
|
||||
github.com/superseriousbusiness/activity v1.9.0-gts.0.20250122115604-584771cb6edc
|
||||
github.com/superseriousbusiness/httpsig v1.2.0-SSB
|
||||
github.com/superseriousbusiness/oauth2/v4 v4.3.2-SSB.0.20230227143000-f4900831d6c8
|
||||
github.com/tdewolff/minify/v2 v2.21.2
|
||||
|
|
4
go.sum
generated
4
go.sum
generated
|
@ -526,8 +526,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
|
|||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||
github.com/superseriousbusiness/activity v1.9.0-gts.0.20250121090817-0ef92d24eba1 h1:bFHT+Qww4wJmcNqRdv8pXEc5t1RvVO8neSd/K6Csu9w=
|
||||
github.com/superseriousbusiness/activity v1.9.0-gts.0.20250121090817-0ef92d24eba1/go.mod h1:9l74ZCv8zw07vipNMzahq8oQZt2xPaJZ+L+gLicQntQ=
|
||||
github.com/superseriousbusiness/activity v1.9.0-gts.0.20250122115604-584771cb6edc h1:9kb/xF1/UlmW/aQ/s8P/Ob+QtW6o7GRr+6xrbPaRUto=
|
||||
github.com/superseriousbusiness/activity v1.9.0-gts.0.20250122115604-584771cb6edc/go.mod h1:9l74ZCv8zw07vipNMzahq8oQZt2xPaJZ+L+gLicQntQ=
|
||||
github.com/superseriousbusiness/go-jpeg-image-structure/v2 v2.0.0-20220321154430-d89a106fdabe h1:ksl2oCx/Qo8sNDc3Grb8WGKBM9nkvhCm25uvlT86azE=
|
||||
github.com/superseriousbusiness/go-jpeg-image-structure/v2 v2.0.0-20220321154430-d89a106fdabe/go.mod h1:gH4P6gN1V+wmIw5o97KGaa1RgXB/tVpC2UNzijhg3E4=
|
||||
github.com/superseriousbusiness/go-png-image-structure/v2 v2.0.1-SSB h1:8psprYSK1KdOSH7yQ4PbJq0YYaGQY+gzdW/B0ExDb/8=
|
||||
|
|
128
vendor/github.com/superseriousbusiness/activity/pub/side_effect_actor.go
generated
vendored
128
vendor/github.com/superseriousbusiness/activity/pub/side_effect_actor.go
generated
vendored
|
@ -5,7 +5,6 @@
|
|||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
|
||||
"github.com/superseriousbusiness/activity/streams"
|
||||
"github.com/superseriousbusiness/activity/streams/vocab"
|
||||
|
@ -778,20 +777,30 @@ func (a *SideEffectActor) prepare(
|
|||
|
||||
// We now need to dereference the actor or collection
|
||||
// IRIs to derive inboxes that we can POST requests to.
|
||||
//
|
||||
var (
|
||||
inboxes = make([]*url.URL, 0, len(actorsAndCollections))
|
||||
derefdEntries = make(map[string]struct{}, len(actorsAndCollections))
|
||||
)
|
||||
|
||||
// First check if the implemented database logic
|
||||
// can return any of these inboxes without having
|
||||
// to make remote dereference calls (much cheaper).
|
||||
inboxesFromDB := []*url.URL{}
|
||||
for _, actorOrCollection := range actorsAndCollections {
|
||||
actorOrCollectionStr := actorOrCollection.String()
|
||||
if _, derefd := derefdEntries[actorOrCollectionStr]; derefd {
|
||||
// Ignore potential duplicates
|
||||
// we've already derefd to inbox(es).
|
||||
continue
|
||||
}
|
||||
|
||||
// BEGIN LOCK
|
||||
unlock, err := a.db.Lock(ctx, actorOrCollection)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Try to get inbox(es) for this actor or collection IRI.
|
||||
inboxes, err := a.db.InboxesForIRI(ctx, actorOrCollection)
|
||||
// Try to get inbox(es) for this actor or collection.
|
||||
gotInboxes, err := a.db.InboxesForIRI(ctx, actorOrCollection)
|
||||
|
||||
// END LOCK
|
||||
unlock()
|
||||
|
@ -800,20 +809,16 @@ func (a *SideEffectActor) prepare(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if len(inboxes) > 0 {
|
||||
// We have a hit.
|
||||
inboxesFromDB = append(inboxesFromDB, inboxes...)
|
||||
|
||||
// Since we found one or more inboxes for this iri,
|
||||
// we should remove it from the list of actors and
|
||||
// collections we still need to deref to inboxes.
|
||||
actorsAndCollections = slices.DeleteFunc(
|
||||
actorsAndCollections,
|
||||
func(t *url.URL) bool {
|
||||
return t.String() == actorOrCollection.String()
|
||||
},
|
||||
)
|
||||
if len(gotInboxes) == 0 {
|
||||
// No hit(s).
|
||||
continue
|
||||
}
|
||||
|
||||
// We have one or more hits.
|
||||
inboxes = append(inboxes, gotInboxes...)
|
||||
|
||||
// Mark this actor or collection as deref'd.
|
||||
derefdEntries[actorOrCollectionStr] = struct{}{}
|
||||
}
|
||||
|
||||
// Now look for any remaining actors/collections
|
||||
|
@ -827,29 +832,32 @@ func(t *url.URL) bool {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Fetch remaining actors, unpacking collection
|
||||
// IRIs into Actor IRIs and then into Actor types.
|
||||
// Make HTTP calls to unpack collection IRIs into
|
||||
// Actor IRIs and then into Actor types, ignoring
|
||||
// actors or collections we've already deref'd.
|
||||
actorsFromRemote, err := a.resolveActors(
|
||||
ctx,
|
||||
t,
|
||||
actorsAndCollections,
|
||||
0,
|
||||
a.s2s.MaxDeliveryRecursionDepth(ctx),
|
||||
derefdEntries,
|
||||
0, a.s2s.MaxDeliveryRecursionDepth(ctx),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Extract inbox IRI from each Actor type.
|
||||
// Release no-longer-needed collections.
|
||||
clear(derefdEntries)
|
||||
clear(actorsAndCollections)
|
||||
|
||||
// Extract inbox IRI from each deref'd Actor (if any).
|
||||
inboxesFromRemote, err := actorsToInboxIRIs(actorsFromRemote)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Combine db-discovered inboxes and deref-discovered
|
||||
// inboxes to a final list of destination inboxes.
|
||||
inboxes := []*url.URL{}
|
||||
inboxes = append(inboxes, inboxesFromDB...)
|
||||
// Combine db-discovered inboxes and remote-discovered
|
||||
// inboxes into a final list of destination inboxes.
|
||||
inboxes = append(inboxes, inboxesFromRemote...)
|
||||
|
||||
// POST FILTERING
|
||||
|
@ -919,37 +927,73 @@ func(t *url.URL) bool {
|
|||
// instances of actorObject. It attempts to apply recursively when it encounters
|
||||
// a target that is a Collection or OrderedCollection.
|
||||
//
|
||||
// Any IRI strings in the ignores map will be skipped (use this when
|
||||
// you've already dereferenced some of the actorAndCollectionIRIs).
|
||||
//
|
||||
// If maxDepth is zero or negative, then recursion is infinitely applied.
|
||||
//
|
||||
// If a recipient is a Collection or OrderedCollection, then the server MUST
|
||||
// dereference the collection, WITH the user's credentials.
|
||||
//
|
||||
// Note that this also applies to CollectionPage and OrderedCollectionPage.
|
||||
func (a *SideEffectActor) resolveActors(c context.Context, t Transport, r []*url.URL, depth, maxDepth int) (actors []vocab.Type, err error) {
|
||||
func (a *SideEffectActor) resolveActors(
|
||||
ctx context.Context,
|
||||
t Transport,
|
||||
actorAndCollectionIRIs []*url.URL,
|
||||
ignores map[string]struct{},
|
||||
depth, maxDepth int,
|
||||
) ([]vocab.Type, error) {
|
||||
if maxDepth > 0 && depth >= maxDepth {
|
||||
return
|
||||
// Hit our max depth.
|
||||
return nil, nil
|
||||
}
|
||||
for _, u := range r {
|
||||
var act vocab.Type
|
||||
var more []*url.URL
|
||||
// TODO: Determine if more logic is needed here for inaccessible
|
||||
// collections owned by peer servers.
|
||||
act, more, err = a.dereferenceForResolvingInboxes(c, t, u)
|
||||
|
||||
if len(actorAndCollectionIRIs) == 0 {
|
||||
// Nothing to do.
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Optimistically assume 1:1 mapping of IRIs to actors.
|
||||
actors := make([]vocab.Type, 0, len(actorAndCollectionIRIs))
|
||||
|
||||
// Deref each actorOrCollectionIRI if not ignored.
|
||||
for _, actorOrCollectionIRI := range actorAndCollectionIRIs {
|
||||
_, ignore := ignores[actorOrCollectionIRI.String()]
|
||||
if ignore {
|
||||
// Don't try to
|
||||
// deref this one.
|
||||
continue
|
||||
}
|
||||
|
||||
// TODO: Determine if more logic is needed here for
|
||||
// inaccessible collections owned by peer servers.
|
||||
actor, more, err := a.dereferenceForResolvingInboxes(ctx, t, actorOrCollectionIRI)
|
||||
if err != nil {
|
||||
// Missing recipient -- skip.
|
||||
continue
|
||||
}
|
||||
var recurActors []vocab.Type
|
||||
recurActors, err = a.resolveActors(c, t, more, depth+1, maxDepth)
|
||||
|
||||
if actor != nil {
|
||||
// Got a hit.
|
||||
actors = append(actors, actor)
|
||||
}
|
||||
|
||||
// If this was a collection, get more.
|
||||
recurActors, err := a.resolveActors(
|
||||
ctx,
|
||||
t,
|
||||
more,
|
||||
ignores,
|
||||
depth+1, maxDepth,
|
||||
)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if act != nil {
|
||||
actors = append(actors, act)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
actors = append(actors, recurActors...)
|
||||
}
|
||||
return
|
||||
|
||||
return actors, nil
|
||||
}
|
||||
|
||||
// dereferenceForResolvingInboxes dereferences an IRI solely for finding an
|
||||
|
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -653,7 +653,7 @@ github.com/stretchr/testify/suite
|
|||
# github.com/subosito/gotenv v1.6.0
|
||||
## explicit; go 1.18
|
||||
github.com/subosito/gotenv
|
||||
# github.com/superseriousbusiness/activity v1.9.0-gts.0.20250121090817-0ef92d24eba1
|
||||
# github.com/superseriousbusiness/activity v1.9.0-gts.0.20250122115604-584771cb6edc
|
||||
## explicit; go 1.21
|
||||
github.com/superseriousbusiness/activity/pub
|
||||
github.com/superseriousbusiness/activity/streams
|
||||
|
|
Loading…
Reference in a new issue