aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2023-01-04 02:10:38 +0000
committerJulio Capote <jcapote@gmail.com>2023-01-04 02:10:38 +0000
commitb74190b22474986c20149b3a4a527a684f4ee3ce (patch)
treec61550b0990b946a5db41c0177f705e6ecc87744 /views
parent8f83ac669faa22a684176f8ae796f088f4cde8b6 (diff)
downloadcommunique-b74190b22474986c20149b3a4a527a684f4ee3ce.tar.gz
render publickeypem in actor endpoints
Diffstat (limited to 'views')
-rw-r--r--views/actor.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/views/actor.go b/views/actor.go
index a91044a..48aaa0b 100644
--- a/views/actor.go
+++ b/views/actor.go
@@ -7,7 +7,7 @@ import (
"github.com/go-fed/activity/streams"
)
-func RenderActor(name, domain string) (map[string]interface{}, error) {
+func RenderActor(name, domain, pem string) (map[string]interface{}, error) {
inbox, err := urls.UrlInbox(name, domain)
if err != nil {
return nil, err
@@ -29,6 +29,11 @@ func RenderActor(name, domain string) (map[string]interface{}, error) {
return nil, err
}
+ actorUrlKey, err := urls.UrlProfileKey(name, domain)
+ if err != nil {
+ return nil, err
+ }
+
followingUrl, err := urls.UrlFollowing(name, domain)
if err != nil {
return nil, err
@@ -70,5 +75,23 @@ func RenderActor(name, domain string) (map[string]interface{}, error) {
followingProp.SetIRI(followingUrl)
p.SetActivityStreamsFollowing(followingProp)
+ pemProp := streams.NewW3IDSecurityV1PublicKeyPemProperty()
+ pemProp.Set(pem)
+
+ ownerProp := streams.NewW3IDSecurityV1OwnerProperty()
+ ownerProp.Set(actorUrl)
+
+ pubkeyId := streams.NewJSONLDIdProperty()
+ pubkeyId.Set(actorUrlKey)
+
+ pubKey := streams.NewW3IDSecurityV1PublicKey()
+ pubKey.SetW3IDSecurityV1PublicKeyPem(pemProp)
+ pubKey.SetW3IDSecurityV1Owner(ownerProp)
+ pubKey.SetJSONLDId(pubkeyId)
+
+ pubKeyProp := streams.NewW3IDSecurityV1PublicKeyProperty()
+ pubKeyProp.AppendW3IDSecurityV1PublicKey(pubKey)
+ p.SetW3IDSecurityV1PublicKey(pubKeyProp)
+
return streams.Serialize(p)
}