aboutsummaryrefslogtreecommitdiff
path: root/views/actor.go
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2023-01-02 14:08:11 +0000
committerJulio Capote <jcapote@gmail.com>2023-01-02 14:08:11 +0000
commit91a081a2bc16540c37ac76a719ab4dd79608ed5d (patch)
tree59769446d642ec591f7988ed19657fde9480a35c /views/actor.go
parent8d23867d2c6d3c6f0dd9681192b9b8642ceea254 (diff)
downloadcommunique-91a081a2bc16540c37ac76a719ab4dd79608ed5d.tar.gz
rename profile to actor
Diffstat (limited to 'views/actor.go')
-rw-r--r--views/actor.go74
1 files changed, 74 insertions, 0 deletions
diff --git a/views/actor.go b/views/actor.go
new file mode 100644
index 0000000..a91044a
--- /dev/null
+++ b/views/actor.go
@@ -0,0 +1,74 @@
+package views
+
+import (
+ "fmt"
+
+ "git.capotej.com/capotej/communique/urls"
+ "github.com/go-fed/activity/streams"
+)
+
+func RenderActor(name, domain string) (map[string]interface{}, error) {
+ inbox, err := urls.UrlInbox(name, domain)
+ if err != nil {
+ return nil, err
+ }
+
+ inboxProp := streams.NewActivityStreamsInboxProperty()
+ inboxProp.SetIRI(inbox)
+
+ outbox, err := urls.UrlOutbox(name, domain)
+ if err != nil {
+ return nil, err
+ }
+
+ outboxProp := streams.NewActivityStreamsOutboxProperty()
+ outboxProp.SetIRI(outbox)
+
+ actorUrl, err := urls.UrlProfile(name, domain)
+ if err != nil {
+ return nil, err
+ }
+
+ followingUrl, err := urls.UrlFollowing(name, domain)
+ if err != nil {
+ return nil, err
+ }
+
+ followersUrl, err := urls.UrlFollowers(name, domain)
+ if err != nil {
+ return nil, err
+ }
+
+ p := streams.NewActivityStreamsService()
+ idProp := streams.NewJSONLDIdProperty()
+ idProp.Set(actorUrl)
+ p.SetJSONLDId(idProp)
+ p.SetActivityStreamsInbox(inboxProp)
+ p.SetActivityStreamsOutbox(outboxProp)
+
+ nameProp := streams.NewActivityStreamsNameProperty()
+ nameProp.AppendXMLSchemaString(name)
+ p.SetActivityStreamsName(nameProp)
+
+ usernameProp := streams.NewActivityStreamsPreferredUsernameProperty()
+ usernameProp.SetXMLSchemaString(name)
+ p.SetActivityStreamsPreferredUsername(usernameProp)
+
+ urlProp := streams.NewActivityStreamsUrlProperty()
+ urlProp.AppendIRI(actorUrl)
+ p.SetActivityStreamsUrl(urlProp)
+
+ summaryProp := streams.NewActivityStreamsSummaryProperty()
+ summaryProp.AppendXMLSchemaString(fmt.Sprintf("profile for %s", name))
+ p.SetActivityStreamsSummary(summaryProp)
+
+ followersProp := streams.NewActivityStreamsFollowersProperty()
+ followersProp.SetIRI(followersUrl)
+ p.SetActivityStreamsFollowers(followersProp)
+
+ followingProp := streams.NewActivityStreamsFollowingProperty()
+ followingProp.SetIRI(followingUrl)
+ p.SetActivityStreamsFollowing(followingProp)
+
+ return streams.Serialize(p)
+}