summaryrefslogtreecommitdiff
path: root/testrig/testmodels.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-09-23 21:27:35 +0200
committerLibravatar GitHub <noreply@github.com>2022-09-23 20:27:35 +0100
commit69a193dae543641a2db6823fa6493c02f56fafbd (patch)
treec1a0c71d64642db12a17c6770642c3e0af859960 /testrig/testmodels.go
parent[docs] NLnet follow up questions (#846) (diff)
downloadgotosocial-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 'testrig/testmodels.go')
-rw-r--r--testrig/testmodels.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/testrig/testmodels.go b/testrig/testmodels.go
index 80e6e904a..98b23721e 100644
--- a/testrig/testmodels.go
+++ b/testrig/testmodels.go
@@ -55,6 +55,11 @@ func FalseBool() *bool {
return new(bool)
}
+// StringPtr returns a pointer to the given string.
+func StringPtr(in string) *string {
+ return &in
+}
+
// NewTestTokens returns a map of tokens keyed according to which account the token belongs to.
func NewTestTokens() map[string]*gtsmodel.Token {
tokens := map[string]*gtsmodel.Token{
@@ -474,6 +479,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
URL: "http://fossbros-anonymous.io/@foss_satan",
LastWebfingeredAt: time.Time{},
InboxURI: "http://fossbros-anonymous.io/users/foss_satan/inbox",
+ SharedInboxURI: StringPtr("http://fossbros-anonymous.io/inbox"),
OutboxURI: "http://fossbros-anonymous.io/users/foss_satan/outbox",
FollowersURI: "http://fossbros-anonymous.io/users/foss_satan/followers",
FollowingURI: "http://fossbros-anonymous.io/users/foss_satan/following",
@@ -509,6 +515,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
URL: "http://example.org/@some_user",
LastWebfingeredAt: time.Time{},
InboxURI: "http://example.org/users/some_user/inbox",
+ SharedInboxURI: StringPtr(""),
OutboxURI: "http://example.org/users/some_user/outbox",
FollowersURI: "http://example.org/users/some_user/followers",
FollowingURI: "http://example.org/users/some_user/following",
@@ -1832,6 +1839,7 @@ func NewTestFediPeople() map[string]vocab.ActivityStreamsPerson {
URLMustParse("https://unknown-instance.com/users/brand_new_person/following"),
URLMustParse("https://unknown-instance.com/users/brand_new_person/followers"),
URLMustParse("https://unknown-instance.com/users/brand_new_person/inbox"),
+ nil,
URLMustParse("https://unknown-instance.com/users/brand_new_person/outbox"),
URLMustParse("https://unknown-instance.com/users/brand_new_person/collections/featured"),
"brand_new_person",
@@ -1852,6 +1860,7 @@ func NewTestFediPeople() map[string]vocab.ActivityStreamsPerson {
URLMustParse("https://turnip.farm/users/turniplover6969/following"),
URLMustParse("https://turnip.farm/users/turniplover6969/followers"),
URLMustParse("https://turnip.farm/users/turniplover6969/inbox"),
+ URLMustParse("https://turnip.farm/sharedInbox"),
URLMustParse("https://turnip.farm/users/turniplover6969/outbox"),
URLMustParse("https://turnip.farm/users/turniplover6969/collections/featured"),
"turniplover6969",
@@ -2245,6 +2254,7 @@ func newAPPerson(
followingURI *url.URL,
followersURI *url.URL,
inboxURI *url.URL,
+ sharedInboxIRI *url.URL,
outboxURI *url.URL,
featuredURI *url.URL,
username string,
@@ -2286,6 +2296,17 @@ func newAPPerson(
inboxProp.SetIRI(inboxURI)
person.SetActivityStreamsInbox(inboxProp)
+ // shared inbox
+ if sharedInboxIRI != nil {
+ endpointsProp := streams.NewActivityStreamsEndpointsProperty()
+ endpoints := streams.NewActivityStreamsEndpoints()
+ sharedInboxProp := streams.NewActivityStreamsSharedInboxProperty()
+ sharedInboxProp.SetIRI(sharedInboxIRI)
+ endpoints.SetActivityStreamsSharedInbox(sharedInboxProp)
+ endpointsProp.AppendActivityStreamsEndpoints(endpoints)
+ person.SetActivityStreamsEndpoints(endpointsProp)
+ }
+
// outbox
// the activitypub outbox of this user for serving messages
outboxProp := streams.NewActivityStreamsOutboxProperty()