mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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
This commit is contained in:
@ -23,6 +23,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
@ -156,6 +157,19 @@ func (c *converter) ASRepresentationToAccount(ctx context.Context, accountable a
|
||||
acct.InboxURI = accountable.GetActivityStreamsInbox().GetIRI().String()
|
||||
}
|
||||
|
||||
// SharedInboxURI
|
||||
if sharedInboxURI := ap.ExtractSharedInbox(accountable); sharedInboxURI != nil {
|
||||
var sharedInbox string
|
||||
|
||||
// only trust shared inbox if it has at least two domains,
|
||||
// from the right, in common with the domain of the account
|
||||
if dns.CompareDomainName(acct.Domain, sharedInboxURI.Host) >= 2 {
|
||||
sharedInbox = sharedInboxURI.String()
|
||||
}
|
||||
|
||||
acct.SharedInboxURI = &sharedInbox
|
||||
}
|
||||
|
||||
// OutboxURI
|
||||
if accountable.GetActivityStreamsOutbox() != nil && accountable.GetActivityStreamsOutbox().GetIRI() != nil {
|
||||
acct.OutboxURI = accountable.GetActivityStreamsOutbox().GetIRI().String()
|
||||
|
Reference in New Issue
Block a user