Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Extending webfinger response (issue:2851) (#3053)
Jerin Thomas8e6521537dcf
diff --git a/activitypub/apmodels/utils.go b/activitypub/apmodels/utils.goindex 056d527b08..b5fcaf687a 100644--- a/activitypub/apmodels/utils.go+++ b/activitypub/apmodels/utils.go@@ -4,6 +4,7 @@ import ("encoding/json""net/url""path"+ "path/filepath""github.com/go-fed/activity/streams""github.com/go-fed/activity/streams/vocab"@@ -60,3 +61,50 @@ func Serialize(obj vocab.Type) ([]byte, error) {return b, err}++// MakeLocalIRIForStreamURL will return a full IRI for the local server stream url.+func MakeLocalIRIForStreamURL() *url.URL {+ host := data.GetServerURL()+ u, err := url.Parse(host)+ if err != nil {+ log.Errorln("unable to parse local IRI stream url", err)+ return nil+ }++ u.Path = path.Join(u.Path, "/hls/stream.m3u8")++ return u+}++// MakeLocalIRIforLogo will return a full IRI for the local server logo.+func MakeLocalIRIforLogo() *url.URL {+ host := data.GetServerURL()+ u, err := url.Parse(host)+ if err != nil {+ log.Errorln("unable to parse local IRI stream url", err)+ return nil+ }++ u.Path = path.Join(u.Path, "/logo/external")++ return u+}++// GetLogoType will return the rel value for the webfinger response and+// the default static image is of type png.+func GetLogoType() string {+ imageFilename := data.GetLogoPath()+ if imageFilename == "" {+ return "image/png"+ }++ logoType := "image/jpeg"+ if filepath.Ext(imageFilename) == ".svg" {+ logoType = "image/svg+xml"+ } else if filepath.Ext(imageFilename) == ".gif" {+ logoType = "image/gif"+ } else if filepath.Ext(imageFilename) == ".png" {+ logoType = "image/png"+ }+ return logoType+}diff --git a/activitypub/apmodels/webfinger.go b/activitypub/apmodels/webfinger.goindex 316cbe8948..f8151ca9dd 100644--- a/activitypub/apmodels/webfinger.go+++ b/activitypub/apmodels/webfinger.go@@ -26,7 +26,9 @@ type Link struct {// MakeWebfingerResponse will create a new Webfinger response.func MakeWebfingerResponse(account string, inbox string, host string) WebfingerResponse {accountIRI := MakeLocalIRIForAccount(account)-+ streamIRI := MakeLocalIRIForStreamURL()+ logoIRI := MakeLocalIRIforLogo()+ logoType := GetLogoType()return WebfingerResponse{Subject: fmt.Sprintf("acct:%s@%s", account, host),Aliases: []string{@@ -43,6 +45,16 @@ func MakeWebfingerResponse(account string, inbox string, host string) WebfingerRType: "text/html",Href: accountIRI.String(),},+ {+ Rel: "http://webfinger.net/rel/avatar",+ Type: logoType,+ Href: logoIRI.String(),+ },+ {+ Rel: "alternate",+ Type: "application/x-mpegURL",+ Href: streamIRI.String(),+ },},}}