mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-22 11:46:40 +00:00
lil webfingy fix (#106)
* lil webfingy fix * return requested content type from fede requests
This commit is contained in:
parent
29bdc41baa
commit
113186ce4e
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
@ -55,12 +57,20 @@ func (m *Module) FollowersGETHandler(c *gin.Context) {
|
||||||
ctx = context.WithValue(ctx, util.APRequestingPublicKeyVerifier, verifier)
|
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 {
|
if err != nil {
|
||||||
l.Info(err.Error())
|
l.Info(err.Error())
|
||||||
c.JSON(err.Code(), gin.H{"error": err.Safe()})
|
c.JSON(err.Code(), gin.H{"error": err.Safe()})
|
||||||
return
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
@ -55,12 +57,20 @@ func (m *Module) FollowingGETHandler(c *gin.Context) {
|
||||||
ctx = context.WithValue(ctx, util.APRequestingPublicKeyVerifier, verifier)
|
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 {
|
if err != nil {
|
||||||
l.Info(err.Error())
|
l.Info(err.Error())
|
||||||
c.JSON(err.Code(), gin.H{"error": err.Safe()})
|
c.JSON(err.Code(), gin.H{"error": err.Safe()})
|
||||||
return
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
@ -48,5 +50,13 @@ func (m *Module) PublicKeyGETHandler(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, user)
|
b, mErr := json.Marshal(user)
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
@ -50,5 +52,13 @@ func (m *Module) StatusGETHandler(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, status)
|
b, mErr := json.Marshal(status)
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
@ -70,5 +72,13 @@ func (m *Module) UsersGETHandler(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, user)
|
b, mErr := json.Marshal(user)
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ func (m *Module) WebfingerGETRequest(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if accountDomain != m.config.AccountDomain {
|
if accountDomain != m.config.AccountDomain && accountDomain != m.config.Host {
|
||||||
l.Debugf("aborting request because accountDomain %s does not belong to this instance", accountDomain)
|
l.Debugf("aborting request because accountDomain %s does not belong to this instance", accountDomain)
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("accountDomain %s does not belong to this instance", accountDomain)})
|
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("accountDomain %s does not belong to this instance", accountDomain)})
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue