Commit 9fe13ba2 authored by zauberstuhl's avatar zauberstuhl

Fix static webfinger link

parent 8cf9d860
# GangGo Federation Library
Pretty raw federation library for golang to communicate with the diaspora protocol
Federation library for golang to communicate with the diaspora protocol
## Dependencies
For parsing hcard's the library requires a third party lib:
github.com/PuerkitoBio/goquery
......@@ -32,4 +32,8 @@ const (
Comment = "comment"
Like = "like"
Contact = "contact"
// webfinger
WebFingerOstatus = "http://ostatus.org/schema/1.0/subscribe"
WebFingerHcard = "http://microformats.org/profile/hcard"
)
......@@ -33,6 +33,7 @@ type WebfingerXml struct {
XMLName xml.Name `xml:"XRD"`
Xmlns string `xml:"xmlns,attr"`
Subject string `xml:"Subject,omitempty"`
Alias string `xml:"Alias,omitempty"`
Links []WebfingerXmlLink `xml:"Link"`
}
......@@ -45,21 +46,24 @@ type WebfingerXmlLink struct {
}
func (w *WebFinger) Discovery() error {
err := FetchXml("GET", w.Host +
"/.well-known/host-meta", nil, &w.Xrd)
err := FetchXml("GET", w.Host + "/.well-known/host-meta", nil, &w.Xrd)
if err != nil {
return err
}
if len(w.Xrd.Links) < 1 {
return errors.New("XRD Link missing")
}
discoveryUrl := strings.Replace(
w.Xrd.Links[0].Template,
"{uri}", "acct:" + w.Handle, 1,
)
err = FetchXml("GET", discoveryUrl, nil, &w.Xrd)
if err != nil {
return err
for _, link := range w.Xrd.Links {
if link.Rel == "lrdd" && link.Template != "" {
err = FetchXml("GET", strings.Replace(
link.Template, "{uri}", "acct:" + w.Handle, 1), nil, &w.Xrd)
if err != nil {
return err
}
return nil
}
}
return nil
return errors.New("No lrdd rel found in webfinger document!")
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment