aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2023-01-07 22:54:38 +0000
committerJulio Capote <jcapote@gmail.com>2023-01-07 22:54:38 +0000
commit14963269dc63bf038163a851e521d6815ab5f514 (patch)
treed85f0b5cfebe22924e0068ce1b47b65c79953331 /views
parentaf05fbea27df62c96b411a941cf5bb612f256e9d (diff)
downloadcommunique-14963269dc63bf038163a851e521d6815ab5f514.tar.gz
avatar support
Diffstat (limited to '')
-rw-r--r--views/actor.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/views/actor.go b/views/actor.go
index 48aaa0b..bc89f95 100644
--- a/views/actor.go
+++ b/views/actor.go
@@ -7,7 +7,7 @@ import (
"github.com/go-fed/activity/streams"
)
-func RenderActor(name, domain, pem string) (map[string]interface{}, error) {
+func RenderActor(name, domain, pem, mediaType string) (map[string]interface{}, error) {
inbox, err := urls.UrlInbox(name, domain)
if err != nil {
return nil, err
@@ -34,6 +34,11 @@ func RenderActor(name, domain, pem string) (map[string]interface{}, error) {
return nil, err
}
+ actorAvatarUrl, err := urls.UrlActorAvatar(name, domain)
+ if err != nil {
+ return nil, err
+ }
+
followingUrl, err := urls.UrlFollowing(name, domain)
if err != nil {
return nil, err
@@ -51,6 +56,18 @@ func RenderActor(name, domain, pem string) (map[string]interface{}, error) {
p.SetActivityStreamsInbox(inboxProp)
p.SetActivityStreamsOutbox(outboxProp)
+ image := streams.NewActivityStreamsImage()
+ mediaTypeProp := streams.NewActivityStreamsMediaTypeProperty()
+ mediaTypeProp.Set(mediaType)
+ image.SetActivityStreamsMediaType(mediaTypeProp)
+ urlProp := streams.NewActivityStreamsUrlProperty()
+ urlProp.AppendIRI(actorAvatarUrl)
+ image.SetActivityStreamsUrl(urlProp)
+
+ iconProp := streams.NewActivityStreamsIconProperty()
+ iconProp.AppendActivityStreamsImage(image)
+ p.SetActivityStreamsIcon(iconProp)
+
nameProp := streams.NewActivityStreamsNameProperty()
nameProp.AppendXMLSchemaString(name)
p.SetActivityStreamsName(nameProp)
@@ -59,7 +76,7 @@ func RenderActor(name, domain, pem string) (map[string]interface{}, error) {
usernameProp.SetXMLSchemaString(name)
p.SetActivityStreamsPreferredUsername(usernameProp)
- urlProp := streams.NewActivityStreamsUrlProperty()
+ urlProp = streams.NewActivityStreamsUrlProperty()
urlProp.AppendIRI(actorUrl)
p.SetActivityStreamsUrl(urlProp)