aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--http/router.go2
-rw-r--r--registry/registry.go21
-rw-r--r--sample-config.toml2
-rw-r--r--urls/urls.go13
4 files changed, 32 insertions, 6 deletions
diff --git a/http/router.go b/http/router.go
index 204243f..04fa583 100644
--- a/http/router.go
+++ b/http/router.go
@@ -96,7 +96,7 @@ func (s *Router) Start(zapWriter io.Writer) {
actorParam := c.Param("actor")
idParam := c.Param("id")
var resource map[string]interface{}
- resource, _ = s.registry.Activity(actorParam, idParam)
+ resource, _ = s.registry.Note(actorParam, idParam)
if resource != nil {
c.Writer.Header().Set("Content-Type", "application/activity+json")
diff --git a/registry/registry.go b/registry/registry.go
index 4a1329a..13f2889 100644
--- a/registry/registry.go
+++ b/registry/registry.go
@@ -96,6 +96,27 @@ func (r *Registry) Activity(name, id string) (map[string]interface{}, error) {
return views.RenderActivity(handler.handlerCfg.Name, r.cfg.Domain, outboxItem)
}
+func (r *Registry) Note(name, id string) (map[string]interface{}, error) {
+ handler := r.findByName(name)
+ if handler == nil {
+ return nil, nil
+ }
+ lookup := models.NewOutboxItem(handler.handlerCfg)
+ lookup.Id = []byte(id)
+ result, err := r.persister.Find(lookup)
+ if err != nil {
+ return nil, err
+ }
+ buf := bytes.NewBuffer(result)
+ dec := gob.NewDecoder(buf)
+ var outboxItem models.OutboxItem
+ err = dec.Decode(&outboxItem)
+ if err != nil {
+ return nil, err
+ }
+ return views.RenderNote(handler.handlerCfg.Name, r.cfg.Domain, outboxItem)
+}
+
func (r *Registry) WebfingerResource(fqn string) (*views.WebfingerResource, error) {
handler := r.findByFQN(fqn)
if handler == nil {
diff --git a/sample-config.toml b/sample-config.toml
index a89678a..218660a 100644
--- a/sample-config.toml
+++ b/sample-config.toml
@@ -6,7 +6,7 @@ name = "sample"
rpc = "cgi" # rename to protocol?
# add response type? like Note
exec = "sample-cgi-handler.sh"
-interval = "5s"
+interval = "55s"
# [[handlers]]
# name = "another"
diff --git a/urls/urls.go b/urls/urls.go
index 98ba922..91e0b37 100644
--- a/urls/urls.go
+++ b/urls/urls.go
@@ -7,7 +7,8 @@ import (
)
func UrlInbox(name, domain string) (*url.URL, error) {
- u, err := url.Parse(path.Join("https://", domain, "actors", name, "inbox"))
+ u, err := url.Parse(path.Join(domain, "actors", name, "inbox"))
+ u.Scheme = "https"
if err != nil {
return nil, fmt.Errorf("could not build inbox url: %w", err)
}
@@ -15,7 +16,8 @@ func UrlInbox(name, domain string) (*url.URL, error) {
}
func UrlOutbox(name, domain string) (*url.URL, error) {
- u, err := url.Parse(path.Join("https://", domain, "actors", name, "outbox"))
+ u, err := url.Parse(path.Join(domain, "actors", name, "outbox"))
+ u.Scheme = "https"
if err != nil {
return nil, fmt.Errorf("could not build outbox url: %w", err)
}
@@ -23,7 +25,8 @@ func UrlOutbox(name, domain string) (*url.URL, error) {
}
func UrlActivity(name, domain, id string) (*url.URL, error) {
- u, err := url.Parse(path.Join(domain, "actors", name, "outbox", id, "activity"))
+ u, err := url.Parse(path.Join(domain, "actors", name, "activity", id))
+ u.Scheme = "https"
if err != nil {
return nil, fmt.Errorf("could not build activity url: %w", err)
}
@@ -31,7 +34,8 @@ func UrlActivity(name, domain, id string) (*url.URL, error) {
}
func UrlNote(name, domain, id string) (*url.URL, error) {
- u, err := url.Parse(path.Join("https://", domain, "actors", name, "outbox", id, "note"))
+ u, err := url.Parse(path.Join(domain, "actors", name, "activity", id, "note"))
+ u.Scheme = "https"
if err != nil {
return nil, fmt.Errorf("could not build note url: %w", err)
}
@@ -40,6 +44,7 @@ func UrlNote(name, domain, id string) (*url.URL, error) {
func UrlOutboxPage(name, domain string) (*url.URL, error) {
u, err := UrlOutbox(name, domain)
+ u.Scheme = "https"
if err != nil {
return nil, fmt.Errorf("could not build outbox page url: %w", err)
}