From 14963269dc63bf038163a851e521d6815ab5f514 Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Sat, 7 Jan 2023 17:54:38 -0500 Subject: avatar support --- views/actor.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'views/actor.go') 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) -- cgit v1.2.3