diff options
Diffstat (limited to 'internal/api/s2s/user/following.go')
-rw-r--r-- | internal/api/s2s/user/following.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/internal/api/s2s/user/following.go b/internal/api/s2s/user/following.go index bdf815b05..4c010dbe0 100644 --- a/internal/api/s2s/user/following.go +++ b/internal/api/s2s/user/following.go @@ -20,6 +20,8 @@ package user import ( "context" + "encoding/json" + "fmt" "net/http" "github.com/gin-gonic/gin" @@ -55,12 +57,20 @@ func (m *Module) FollowingGETHandler(c *gin.Context) { ctx = context.WithValue(ctx, util.APRequestingPublicKeyVerifier, verifier) } - user, err := m.processor.GetFediFollowing(ctx, requestedUsername, c.Request.URL) // handles auth as well + following, err := m.processor.GetFediFollowing(ctx, requestedUsername, c.Request.URL) // handles auth as well if err != nil { l.Info(err.Error()) c.JSON(err.Code(), gin.H{"error": err.Safe()}) return } - c.JSON(http.StatusOK, user) + b, mErr := json.Marshal(following) + if mErr != nil { + err := fmt.Errorf("could not marshal json: %s", mErr) + l.Error(err) + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } + + c.Data(http.StatusOK, format, b) } |