From 69a193dae543641a2db6823fa6493c02f56fafbd Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 23 Sep 2022 21:27:35 +0200 Subject: [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 --- internal/federation/federatingdb/inbox.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'internal/federation/federatingdb/inbox.go') diff --git a/internal/federation/federatingdb/inbox.go b/internal/federation/federatingdb/inbox.go index b3b935bff..18f620bce 100644 --- a/internal/federation/federatingdb/inbox.go +++ b/internal/federation/federatingdb/inbox.go @@ -108,7 +108,15 @@ func (f *federatingDB) InboxesForIRI(c context.Context, iri *url.URL) (inboxIRIs follow.Account = followingAccount } - inboxIRI, err := url.Parse(follow.Account.InboxURI) + // deliver to a shared inbox if we have that option + var inbox string + if config.GetInstanceDeliverToSharedInboxes() && follow.Account.SharedInboxURI != nil && *follow.Account.SharedInboxURI != "" { + inbox = *follow.Account.SharedInboxURI + } else { + inbox = follow.Account.InboxURI + } + + inboxIRI, err := url.Parse(inbox) if err != nil { return nil, fmt.Errorf("error parsing inbox uri of following account %s: %s", follow.Account.InboxURI, err) } @@ -119,7 +127,15 @@ func (f *federatingDB) InboxesForIRI(c context.Context, iri *url.URL) (inboxIRIs // check if this is just an account IRI... if account, err := f.db.GetAccountByURI(c, iri.String()); err == nil { - inboxIRI, err := url.Parse(account.InboxURI) + // deliver to a shared inbox if we have that option + var inbox string + if config.GetInstanceDeliverToSharedInboxes() && account.SharedInboxURI != nil && *account.SharedInboxURI != "" { + inbox = *account.SharedInboxURI + } else { + inbox = account.InboxURI + } + + inboxIRI, err := url.Parse(inbox) if err != nil { return nil, fmt.Errorf("error parsing account inbox uri %s: %s", account.InboxURI, account.InboxURI) } -- cgit v1.2.3