diff options
author | Julio Capote <jcapote@gmail.com> | 2023-01-02 02:57:23 +0000 |
---|---|---|
committer | Julio Capote <jcapote@gmail.com> | 2023-01-02 02:57:23 +0000 |
commit | 2148666991eb98fa6935f4f36fc29cf1e704f834 (patch) | |
tree | df9ef2db74685543d7458650b69ce89db14ae51a /views | |
parent | 5efad50005484e4bcd56fd68a46040e3d89b0efe (diff) | |
download | communique-2148666991eb98fa6935f4f36fc29cf1e704f834.tar.gz |
followers and following endpoints
Diffstat (limited to 'views')
-rw-r--r-- | views/outbox.go | 8 | ||||
-rw-r--r-- | views/profile.go | 61 |
2 files changed, 65 insertions, 4 deletions
diff --git a/views/outbox.go b/views/outbox.go index ee28842..8aef906 100644 --- a/views/outbox.go +++ b/views/outbox.go @@ -57,6 +57,14 @@ func RenderOutboxCollection(name, domain string, page []models.OutboxItem) (map[ crea.SetActivityStreamsTo(toProp) crea.SetActivityStreamsPublished(publishedProp) + actorUrl, err := urls.UrlProfile(name, domain) + if err != nil { + return nil, err + } + actorProp := streams.NewActivityStreamsActorProperty() + actorProp.AppendIRI(actorUrl) + crea.SetActivityStreamsActor(actorProp) + noteUrl, err := urls.UrlNote(name, domain, string(v.Id)) if err != nil { return nil, err diff --git a/views/profile.go b/views/profile.go index 12aae54..5b82b46 100644 --- a/views/profile.go +++ b/views/profile.go @@ -1,21 +1,74 @@ package views import ( + "fmt" + "git.capotej.com/capotej/communique/urls" "github.com/go-fed/activity/streams" ) func RenderProfile(name, domain string) (map[string]interface{}, error) { - u, err := urls.UrlInbox(name, domain) + 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 } - inb := streams.NewActivityStreamsInboxProperty() - inb.SetIRI(u) + followersUrl, err := urls.UrlFollowers(name, domain) + if err != nil { + return nil, err + } p := streams.NewActivityStreamsService() - p.SetActivityStreamsInbox(inb) + 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) } |