From a4288b06bf13210721c8f2fae64bc12c118f9041 Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Thu, 29 Dec 2022 15:08:16 -0500 Subject: refactor --- views/webfinger.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 views/webfinger.go (limited to 'views/webfinger.go') diff --git a/views/webfinger.go b/views/webfinger.go new file mode 100644 index 0000000..4252bae --- /dev/null +++ b/views/webfinger.go @@ -0,0 +1,32 @@ +package views + +import ( + "fmt" + "path" +) + +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 RenderWebfingerResource(name, domain string) (*WebfingerResource, error) { + rs := WebfingerResource{ + // TODO clean up + Subject: fmt.Sprintf("acct:%s@%s", name, domain), + Aliases: []string{}, + Links: []Link{{ + Rel: "self", + Href: path.Join("https://", domain, "actors", name), + Type: "application/activity+json", + }}, + } + return &rs, nil +} -- cgit v1.2.3