package views import ( "fmt" "git.capotej.com/capotej/communique/urls" ) type Link struct { Rel string `json:"rel"` Type string `json:"type"` Href string `json:"href"` } type WebfingerResource struct { Subject string `json:"subject"` Aliases []string `json:"aliases"` Links []Link `json:"links"` } func RenderWebfinger(name, domain, hostname string) (*WebfingerResource, error) { actorUrl, err := urls.UrlProfile(name, domain) if err != nil { return nil, err } rs := WebfingerResource{ Subject: fmt.Sprintf("acct:%s%s", name, hostname), //hostname contains @ Aliases: []string{actorUrl.String()}, Links: []Link{{ Rel: "self", Href: actorUrl.String(), Type: "application/activity+json", }}, } return &rs, nil }