aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2022-12-17 21:35:26 +0000
committerJulio Capote <jcapote@gmail.com>2022-12-17 21:35:26 +0000
commit0e1e52b457a452e1cf4f852b88288cb324165f54 (patch)
tree2b7d1f006025f6160d4516b5b5da4a09f8e9ddfc
parent5e51c63643fd4dcb17a23af08bb25cf47fad7650 (diff)
downloadcommunique-0e1e52b457a452e1cf4f852b88288cb324165f54.tar.gz
refactor webfinger package into resources
-rw-r--r--registry/registry.go18
-rw-r--r--resources/webfinger.go (renamed from webfinger/webfinger.go)4
2 files changed, 13 insertions, 9 deletions
diff --git a/registry/registry.go b/registry/registry.go
index fc0e9d9..438f821 100644
--- a/registry/registry.go
+++ b/registry/registry.go
@@ -2,9 +2,10 @@ package registry
import (
"fmt"
+ "path"
"git.capotej.com/capotej/communique/config"
- "git.capotej.com/capotej/communique/webfinger"
+ "git.capotej.com/capotej/communique/resources"
)
type Handler struct {
@@ -26,22 +27,25 @@ func NewRegistry(cfg config.Config) *Registry {
return &reg
}
-func (r *Registry) LookupByName(name string) *webfinger.Resource {
+func (r *Registry) LookupByName(name string) *resources.WebfingerResource {
fqdn := fmt.Sprintf("acct:%s@%s", name, r.cfg.Domain)
return r.LookupResource(fqdn)
}
-func (r *Registry) LookupResource(fqdn string) *webfinger.Resource {
+func (r *Registry) LookupResource(fqdn string) *resources.WebfingerResource {
handler, ok := r.handlerMap[fqdn]
if !ok {
return nil
}
- rs := webfinger.Resource{
- Subject: fmt.Sprintf("acct:%s@%s", handler.handlerCfg.Name, "activitybub.xyz"),
+ rs := resources.WebfingerResource{
+ Subject: fmt.Sprintf("acct:%s@%s", handler.handlerCfg.Name, r.cfg.Domain),
Aliases: []string{},
- Links: []webfinger.Link{{
- Rel: "asd",
+ Links: []resources.Link{{
+ Rel: "self",
+ Href: path.Join("https://", r.cfg.Domain, "actors", handler.handlerCfg.Name),
+ Type: "application/activity+json",
}},
}
return &rs
+
}
diff --git a/webfinger/webfinger.go b/resources/webfinger.go
index 8e43dd2..d936519 100644
--- a/webfinger/webfinger.go
+++ b/resources/webfinger.go
@@ -1,4 +1,4 @@
-package webfinger
+package resources
type Link struct {
Rel string `json:"rel"`
@@ -6,7 +6,7 @@ type Link struct {
Href string `json:"href"`
}
-type Resource struct {
+type WebfingerResource struct {
Subject string `json:"subject"`
Aliases []string `json:"aliases"`
Links []Link `json:"links"`