diff options
author | Julio Capote <jcapote@gmail.com> | 2023-01-08 13:47:54 +0000 |
---|---|---|
committer | Julio Capote <jcapote@gmail.com> | 2023-01-08 13:47:54 +0000 |
commit | f50a36d5cc69c095ba4a5d4a3d240c5284e2b234 (patch) | |
tree | ddb4bb323a1d9a5c6d8c068b7571167112a4c6bc /views | |
parent | 9470ad27f2c725ceeaa6ca8c727670d59fdb5588 (diff) | |
download | communique-f50a36d5cc69c095ba4a5d4a3d240c5284e2b234.tar.gz |
summaries and only render if image exists
Diffstat (limited to 'views')
-rw-r--r-- | views/actor.go | 40 |
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() |