From 2148666991eb98fa6935f4f36fc29cf1e704f834 Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Sun, 1 Jan 2023 21:57:23 -0500 Subject: followers and following endpoints --- http/router.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'http') 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") -- cgit v1.2.3