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 /http/router.go | |
parent | 5efad50005484e4bcd56fd68a46040e3d89b0efe (diff) | |
download | communique-2148666991eb98fa6935f4f36fc29cf1e704f834.tar.gz |
followers and following endpoints
Diffstat (limited to 'http/router.go')
-rw-r--r-- | http/router.go | 26 |
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") |