aboutsummaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2023-01-02 02:57:23 +0000
committerJulio Capote <jcapote@gmail.com>2023-01-02 02:57:23 +0000
commit2148666991eb98fa6935f4f36fc29cf1e704f834 (patch)
treedf9ef2db74685543d7458650b69ce89db14ae51a /http
parent5efad50005484e4bcd56fd68a46040e3d89b0efe (diff)
downloadcommunique-2148666991eb98fa6935f4f36fc29cf1e704f834.tar.gz
followers and following endpoints
Diffstat (limited to 'http')
-rw-r--r--http/router.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/http/router.go b/http/router.go
index 04fa583..9730dbf 100644
--- a/http/router.go
+++ b/http/router.go
@@ -47,6 +47,28 @@ func (s *Router) Start(zapWriter io.Writer) {
})
+ router.GET("/actors/:actor/followers", func(c *gin.Context) {
+ actorParam := c.Param("actor")
+ resource, _ := s.registry.Followers(actorParam)
+ if resource != nil {
+ c.Writer.Header().Set("Content-Type", "application/activity+json")
+ c.JSON(http.StatusOK, resource)
+ } else {
+ c.JSON(http.StatusNotFound, nil)
+ }
+ })
+
+ router.GET("/actors/:actor/following", func(c *gin.Context) {
+ actorParam := c.Param("actor")
+ resource, _ := s.registry.Following(actorParam)
+ if resource != nil {
+ c.Writer.Header().Set("Content-Type", "application/activity+json")
+ c.JSON(http.StatusOK, resource)
+ } else {
+ c.JSON(http.StatusNotFound, nil)
+ }
+ })
+
// // Inbox
// router.POST("/actors/:actor/inbox", func(c *gin.Context) {
// actorParam := c.Param("actor")
@@ -81,7 +103,7 @@ func (s *Router) Start(zapWriter io.Writer) {
actorParam := c.Param("actor")
idParam := c.Param("id")
var resource map[string]interface{}
- resource, _ = s.registry.Activity(actorParam, idParam)
+ resource, _ = s.registry.ActivityOrNote("activity", actorParam, idParam)
if resource != nil {
c.Writer.Header().Set("Content-Type", "application/activity+json")
@@ -96,7 +118,7 @@ func (s *Router) Start(zapWriter io.Writer) {
actorParam := c.Param("actor")
idParam := c.Param("id")
var resource map[string]interface{}
- resource, _ = s.registry.Note(actorParam, idParam)
+ resource, _ = s.registry.ActivityOrNote("note", actorParam, idParam)
if resource != nil {
c.Writer.Header().Set("Content-Type", "application/activity+json")