aboutsummaryrefslogtreecommitdiff
path: root/views/webfinger.go
blob: 4252bae636d31e5a44c528a14d5198b0c33ac254 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
}