return requested content type from fede requests

This commit is contained in:
tsmethurst 2021-07-21 17:33:39 +02:00
commit 722b4dd792
5 changed files with 57 additions and 7 deletions

View file

@ -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) FollowersGETHandler(c *gin.Context) {
ctx = context.WithValue(ctx, util.APRequestingPublicKeyVerifier, verifier)
}
user, err := m.processor.GetFediFollowers(ctx, requestedUsername, c.Request.URL) // GetFediUser handles auth as well
followers, err := m.processor.GetFediFollowers(ctx, requestedUsername, c.Request.URL) // GetFediUser 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(followers)
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)
}