diff options
author | 2022-09-23 21:27:35 +0200 | |
---|---|---|
committer | 2022-09-23 20:27:35 +0100 | |
commit | 69a193dae543641a2db6823fa6493c02f56fafbd (patch) | |
tree | c1a0c71d64642db12a17c6770642c3e0af859960 /internal/federation/federatingdb/inbox.go | |
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/federation/federatingdb/inbox.go')
-rw-r--r-- | internal/federation/federatingdb/inbox.go | 20 |
1 files changed, 18 insertions, 2 deletions
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) } |