Add shared inbox support for ActivityPub delivery (#4755)

* feat(ap): add support for shared inboxes to reduce outbound load

* feat(db): refactor ap followers db into followers repository

* fix(ap): use the updated activity library to pull out the shared inbox endpoint

* chore(deps): point at updated build of owncast/activity

* fix(ap): typeless endpoints

* feat(test): update ActivityPub test to support shared inboxes

* chore(test): remove unused variable

* fix: feedback from review. Guard against SSRF/non-HTTPS/local and handle transaction errors
This commit is contained in:
Gabe Kangas
2026-01-22 15:33:22 -08:00
committed by GitHub
parent 7a735e6902
commit de6468ad89
31 changed files with 1033 additions and 410 deletions
+8 -4
View File
@@ -5,6 +5,7 @@ import (
"github.com/owncast/owncast/activitypub/inbox"
"github.com/owncast/owncast/activitypub/outbox"
"github.com/owncast/owncast/activitypub/persistence"
"github.com/owncast/owncast/activitypub/persistence/followersrepository"
"github.com/owncast/owncast/activitypub/workerpool"
"github.com/owncast/owncast/persistence/configrepository"
@@ -42,8 +43,9 @@ func getOutboundWorkerPoolSize() int {
defaultWorkers = 20 // Default for most instances
)
followersRepo := followersrepository.Get()
var followerCount int64
fc, err := persistence.GetFollowerCount()
fc, err := followersRepo.GetCount()
if err != nil {
log.Errorln("Unable to get follower count", err)
return defaultWorkers
@@ -58,7 +60,7 @@ func getOutboundWorkerPoolSize() int {
workers = maxWorkers
}
log.Infof("Initializing ActivityPub outbound worker pool with %d workers for %d followers", workers, followerCount)
log.Debugf("Initializing ActivityPub outbound worker pool with %d workers for %d followers", workers, followerCount)
return workers
}
@@ -79,10 +81,12 @@ func SendDirectFederatedMessage(message, account string) error {
// GetFollowerCount will return the local tracked follower count.
func GetFollowerCount() (int64, error) {
return persistence.GetFollowerCount()
followersRepo := followersrepository.Get()
return followersRepo.GetCount()
}
// GetPendingFollowRequests will return the pending follow requests.
func GetPendingFollowRequests() ([]models.Follower, error) {
return persistence.GetPendingFollowRequests()
followersRepo := followersrepository.Get()
return followersRepo.GetPendingFollowRequests()
}