diff options
author | Julio Capote <jcapote@gmail.com> | 2022-12-19 00:29:19 +0000 |
---|---|---|
committer | Julio Capote <jcapote@gmail.com> | 2022-12-19 00:29:19 +0000 |
commit | 2ee94a66d89de9eb0461f250251af7776aef9976 (patch) | |
tree | 9cb4a3800c18f4f6b5df84d6cb0d861ff6ae8afc /resources | |
parent | 4f8325f5df55628544f13937975f38c6ef5d17ab (diff) | |
download | communique-2ee94a66d89de9eb0461f250251af7776aef9976.tar.gz |
cleanup
Diffstat (limited to '')
-rw-r--r-- | resources/profile.go | 3 | ||||
-rw-r--r-- | resources/webfinger.go | 19 |
2 files changed, 21 insertions, 1 deletions
diff --git a/resources/profile.go b/resources/profile.go index 23b2844..090075c 100644 --- a/resources/profile.go +++ b/resources/profile.go @@ -1,6 +1,7 @@ package resources import ( + "fmt" "net/url" "path" @@ -10,7 +11,7 @@ import ( func RenderProfile(name, domain string) (map[string]interface{}, error) { u, err := url.Parse(path.Join("https://", domain, "actors", name, "inbox")) if err != nil { - panic(err) + return nil, fmt.Errorf("could not partse url: %w", err) } inb := streams.NewActivityStreamsInboxProperty() diff --git a/resources/webfinger.go b/resources/webfinger.go index d936519..e7c47ea 100644 --- a/resources/webfinger.go +++ b/resources/webfinger.go @@ -1,5 +1,10 @@ package resources +import ( + "fmt" + "path" +) + type Link struct { Rel string `json:"rel"` Type string `json:"type"` @@ -11,3 +16,17 @@ type WebfingerResource struct { 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 +} |