aboutsummaryrefslogtreecommitdiff
path: root/views/actor.go
diff options
context:
space:
mode:
Diffstat (limited to 'views/actor.go')
-rw-r--r--views/actor.go40
1 files changed, 22 insertions, 18 deletions
diff --git a/views/actor.go b/views/actor.go
index bc89f95..36f1f0c 100644
--- a/views/actor.go
+++ b/views/actor.go
@@ -1,13 +1,11 @@
package views
import (
- "fmt"
-
"git.capotej.com/capotej/communique/urls"
"github.com/go-fed/activity/streams"
)
-func RenderActor(name, domain, pem, mediaType string) (map[string]interface{}, error) {
+func RenderActor(name, domain, pem, mediaType, summary string) (map[string]interface{}, error) {
inbox, err := urls.UrlInbox(name, domain)
if err != nil {
return nil, err
@@ -56,17 +54,19 @@ func RenderActor(name, domain, pem, mediaType string) (map[string]interface{}, e
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)
+ if mediaType != "" {
+ 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)
@@ -76,12 +76,16 @@ func RenderActor(name, domain, pem, mediaType string) (map[string]interface{}, e
usernameProp.SetXMLSchemaString(name)
p.SetActivityStreamsPreferredUsername(usernameProp)
- urlProp = streams.NewActivityStreamsUrlProperty()
- urlProp.AppendIRI(actorUrl)
- p.SetActivityStreamsUrl(urlProp)
+ actorUrlProp := streams.NewActivityStreamsUrlProperty()
+ actorUrlProp.AppendIRI(actorUrl)
+ p.SetActivityStreamsUrl(actorUrlProp)
summaryProp := streams.NewActivityStreamsSummaryProperty()
- summaryProp.AppendXMLSchemaString(fmt.Sprintf("profile for %s", name))
+ if summary != "" {
+ summaryProp.AppendXMLSchemaString(summary)
+ } else {
+ summaryProp.AppendXMLSchemaString("an activitypub bot on communique (https://git.capotej.com/capotej/communique)")
+ }
p.SetActivityStreamsSummary(summaryProp)
followersProp := streams.NewActivityStreamsFollowersProperty()