aboutsummaryrefslogtreecommitdiff
path: root/registry
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2023-01-01 21:48:37 +0000
committerJulio Capote <jcapote@gmail.com>2023-01-01 21:48:37 +0000
commitb3f22c698739bdd57dab77af45a0b8a43da72ca4 (patch)
tree07d4bca01bc49d71d2ddceaa89f51487f0768047 /registry
parent71495ac61587e3380f413b4d34669a68b5cd8068 (diff)
downloadcommunique-b3f22c698739bdd57dab77af45a0b8a43da72ca4.tar.gz
working ids and activity lookups
Diffstat (limited to 'registry')
-rw-r--r--registry/registry.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/registry/registry.go b/registry/registry.go
index 2518d55..4a1329a 100644
--- a/registry/registry.go
+++ b/registry/registry.go
@@ -14,6 +14,7 @@ type Handler struct {
handlerCfg config.Handler
}
+// TODO rename to controller and controller.go
type Registry struct {
cfg config.Config
persister *models.Persister
@@ -74,6 +75,27 @@ func (r *Registry) OutboxCollection(name string) (map[string]interface{}, error)
return views.RenderOutboxCollection(handler.handlerCfg.Name, r.cfg.Domain, outboxItems)
}
+func (r *Registry) Activity(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.RenderActivity(handler.handlerCfg.Name, r.cfg.Domain, outboxItem)
+}
+
func (r *Registry) WebfingerResource(fqn string) (*views.WebfingerResource, error) {
handler := r.findByFQN(fqn)
if handler == nil {