Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
address activitypub notes to the streamer's follower collection (#4314)
mahmed2000b937848d540c
diff --git a/activitypub/apmodels/activity.go b/activitypub/apmodels/activity.goindex fd4ac057c6..76aa06de60 100644--- a/activitypub/apmodels/activity.go+++ b/activitypub/apmodels/activity.go@@ -31,6 +31,20 @@ func MakeNotePublic(note vocab.ActivityStreamsNote) vocab.ActivityStreamsNote {return note}+func MakeAddressingToFollowers(followers_iri *url.URL, public bool) (vocab.ActivityStreamsToProperty, vocab.ActivityStreamsCcProperty) {+ to := streams.NewActivityStreamsToProperty()+ cc := streams.NewActivityStreamsCcProperty()++ if public {+ public, _ := url.Parse(PUBLIC)+ to.AppendIRI(public)+ cc.AppendIRI(followers_iri)+ } else {+ to.AppendIRI(followers_iri)+ }+ return to, cc+}+// MakeNoteDirect sets the required properties to make this note seen as a// direct message.func MakeNoteDirect(note vocab.ActivityStreamsNote, toIRI *url.URL) vocab.ActivityStreamsNote {diff --git a/activitypub/outbox/outbox.go b/activitypub/outbox/outbox.goindex f9cf7a3157..1baaacc612 100644--- a/activitypub/outbox/outbox.go+++ b/activitypub/outbox/outbox.go@@ -66,11 +66,11 @@ func SendLive() error {activity, _, note, noteID := createBaseOutboundMessage(textContent)- // To the public if we're not treating ActivityPub as "private".- if !configRepository.GetFederationIsPrivate() {- note = apmodels.MakeNotePublic(note)- activity = apmodels.MakeActivityPublic(activity)- }+ to, cc := getAddressingToFollowers()+ note.SetActivityStreamsTo(to)+ note.SetActivityStreamsCc(cc)+ activity.SetActivityStreamsTo(to)+ activity.SetActivityStreamsCc(cc)note.SetActivityStreamsTag(tagProp)@@ -153,8 +153,6 @@ func SendDirectMessageToAccount(textContent, account string) error {// SendPublicMessage will send a public message to all followers.func SendPublicMessage(textContent string) error {- configRepository := configrepository.Get()-originalContent := textContenttextContent = utils.RenderSimpleMarkdown(textContent)@@ -177,10 +175,11 @@ func SendPublicMessage(textContent string) error {activity, _, note, noteID := createBaseOutboundMessage(textContent)note.SetActivityStreamsTag(tagProp)- if !configRepository.GetFederationIsPrivate() {- note = apmodels.MakeNotePublic(note)- activity = apmodels.MakeActivityPublic(activity)- }+ to, cc := getAddressingToFollowers()+ note.SetActivityStreamsTo(to)+ note.SetActivityStreamsCc(cc)+ activity.SetActivityStreamsTo(to)+ activity.SetActivityStreamsCc(cc)b, err := apmodels.Serialize(activity)if err != nil {@@ -199,6 +198,18 @@ func SendPublicMessage(textContent string) error {return nil}+// if public, cc the followers and to the Public uri, else private, address followers directly.+func getAddressingToFollowers() (vocab.ActivityStreamsToProperty, vocab.ActivityStreamsCcProperty) {+ configRepository := configrepository.Get()+ server_url := configRepository.GetServerURL()+ followers_iri, _ := url.Parse(server_url)+ username := configRepository.GetDefaultFederationUsername()++ followers_iri = followers_iri.JoinPath("federation", "user", username, "followers")++ return apmodels.MakeAddressingToFollowers(followers_iri, !configRepository.GetFederationIsPrivate())+}+// nolint: unparamfunc createBaseOutboundMessage(textContent string) (vocab.ActivityStreamsCreate, string, vocab.ActivityStreamsNote, string) {configRepository := configrepository.Get()diff --git a/webserver/handlers/admin/federation.go b/webserver/handlers/admin/federation.goindex fc8aa3d736..8c2c4aaa7c 100644--- a/webserver/handlers/admin/federation.go+++ b/webserver/handlers/admin/federation.go@@ -16,6 +16,13 @@ func SendFederatedMessage(w http.ResponseWriter, r *http.Request) {return}+ configRepository := configrepository.Get()++ if !configRepository.GetFederationEnabled() {+ webutils.WriteSimpleResponse(w, false, "Federation is disabled")+ return+ }+configValue, success := getValueFromRequest(w, r)if !success {return