diff options
author | 2022-09-23 21:27:35 +0200 | |
---|---|---|
committer | 2022-09-23 20:27:35 +0100 | |
commit | 69a193dae543641a2db6823fa6493c02f56fafbd (patch) | |
tree | c1a0c71d64642db12a17c6770642c3e0af859960 /internal/ap | |
parent | [docs] NLnet follow up questions (#846) (diff) | |
download | gotosocial-69a193dae543641a2db6823fa6493c02f56fafbd.tar.xz |
[feature] Allow delivery to sharedInboxes where possible (#847)
* update Activity
* add instance-deliver-to-shared-inboxes setting
* update activity version again
* add SharedInboxURI field to accounts
* serdes for endpoints/sharedInbox
* deliver to sharedInbox if one is available
* update tests
* only assign shared inbox if shared domain
* look for shared inbox if currently nil
* go fmt
* finger to get params.RemoteAccountID if necessary
* make comments clearer
* compare dns more consistently
Diffstat (limited to 'internal/ap')
-rw-r--r-- | internal/ap/extract.go | 30 | ||||
-rw-r--r-- | internal/ap/interfaces.go | 6 |
2 files changed, 36 insertions, 0 deletions
diff --git a/internal/ap/extract.go b/internal/ap/extract.go index e1566059c..2d3a6fd9c 100644 --- a/internal/ap/extract.go +++ b/internal/ap/extract.go @@ -702,3 +702,33 @@ func ExtractSensitive(withSensitive WithSensitive) bool { return false } + +// ExtractSharedInbox extracts the sharedInbox URI properly from an Actor. +// Returns nil if this property is not set. +func ExtractSharedInbox(withEndpoints WithEndpoints) *url.URL { + endpointsProp := withEndpoints.GetActivityStreamsEndpoints() + if endpointsProp == nil { + return nil + } + + for iter := endpointsProp.Begin(); iter != endpointsProp.End(); iter = iter.Next() { + if iter.IsActivityStreamsEndpoints() { + endpoints := iter.Get() + if endpoints == nil { + return nil + } + sharedInboxProp := endpoints.GetActivityStreamsSharedInbox() + if sharedInboxProp == nil { + return nil + } + + if !sharedInboxProp.IsIRI() { + return nil + } + + return sharedInboxProp.GetIRI() + } + } + + return nil +} diff --git a/internal/ap/interfaces.go b/internal/ap/interfaces.go index 35ce937a1..803eda640 100644 --- a/internal/ap/interfaces.go +++ b/internal/ap/interfaces.go @@ -40,6 +40,7 @@ type Accountable interface { WithFollowers WithFeatured WithManuallyApprovesFollowers + WithEndpoints } // Statusable represents the minimum activitypub interface for representing a 'status'. @@ -337,3 +338,8 @@ type WithItems interface { type WithManuallyApprovesFollowers interface { GetActivityStreamsManuallyApprovesFollowers() vocab.ActivityStreamsManuallyApprovesFollowersProperty } + +// WithEndpoints represents a Person or profile with the endpoints property +type WithEndpoints interface { + GetActivityStreamsEndpoints() vocab.ActivityStreamsEndpointsProperty +} |