aboutsummaryrefslogtreecommitdiff
path: root/registry/registry.go
diff options
context:
space:
mode:
Diffstat (limited to 'registry/registry.go')
-rw-r--r--registry/registry.go35
1 files changed, 32 insertions, 3 deletions
diff --git a/registry/registry.go b/registry/registry.go
index 16ae828..bbe3f1c 100644
--- a/registry/registry.go
+++ b/registry/registry.go
@@ -3,6 +3,7 @@ package registry
import (
"bytes"
"encoding/gob"
+ "net/http"
"net/url"
"strings"
@@ -23,13 +24,29 @@ type Registry struct {
handlerMap map[string]Handler
}
-func NewRegistry(cfg config.Config, persister *models.Persister) *Registry {
+func NewRegistry(cfg config.Config, persister *models.Persister) (*Registry, error) {
reg := Registry{cfg: cfg, persister: persister}
reg.handlerMap = make(map[string]Handler)
for _, v := range cfg.Handlers {
reg.handlerMap[v.Name] = Handler{handlerCfg: v}
+ err := generateKeypairIfNeeded(v, persister)
+ if err != nil {
+ return nil, err
+ }
}
- return &reg
+ return &reg, nil
+}
+
+func generateKeypairIfNeeded(v config.Handler, p *models.Persister) error {
+ kp, err := models.CreateKeypair(v)
+ if err != nil {
+ return err
+ }
+ err = p.Store(kp)
+ if err != nil {
+ return err
+ }
+ return nil
}
func (r *Registry) Actor(name string) (map[string]interface{}, error) {
@@ -51,7 +68,7 @@ func (r *Registry) OutboxCollection(name string) (map[string]interface{}, error)
return nil, err
}
var outboxItems []models.OutboxItem
- for _, v := range page[0:20] { //TODO pagination
+ for _, v := range page { //TODO pagination
buf := bytes.NewBuffer(v)
dec := gob.NewDecoder(buf)
var outboxItem models.OutboxItem
@@ -109,6 +126,18 @@ func (r *Registry) Followers(name string) (map[string]interface{}, error) {
return result, nil
}
+func (r *Registry) Inbox(name string, req *http.Request) error {
+ handler := r.findByName(name)
+ if handler == nil {
+ return nil
+ }
+ // verifier, err := httpsig.NewVerifier(req)
+ // if err != nil {
+ // return err
+ // }
+ return nil
+}
+
func (r *Registry) ActivityOrNote(activityOrNote, name, id string) (map[string]interface{}, error) {
handler := r.findByName(name)
if handler == nil {