mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-30 21:12:45 +00:00
Move json errors over to gmsl (#3080)
This commit is contained in:
parent
a49c9f01e2
commit
0489d16f95
109 changed files with 808 additions and 1217 deletions
|
@ -18,7 +18,6 @@ import (
|
|||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
"github.com/matrix-org/dendrite/relayapi/api"
|
||||
"github.com/matrix-org/gomatrixserverlib/fclient"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
|
@ -40,13 +39,13 @@ func GetTransactionFromRelay(
|
|||
if err := json.Unmarshal(fedReq.Content(), &previousEntry); err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: jsonerror.BadJSON("invalid json provided"),
|
||||
JSON: spec.BadJSON("invalid json provided"),
|
||||
}
|
||||
}
|
||||
if previousEntry.EntryID < 0 {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: jsonerror.BadJSON("Invalid entry id provided. Must be >= 0."),
|
||||
JSON: spec.BadJSON("Invalid entry id provided. Must be >= 0."),
|
||||
}
|
||||
}
|
||||
logrus.Infof("Previous entry provided: %v", previousEntry.EntryID)
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
|
||||
"github.com/getsentry/sentry-go"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
"github.com/matrix-org/dendrite/internal/httputil"
|
||||
relayInternal "github.com/matrix-org/dendrite/relayapi/internal"
|
||||
"github.com/matrix-org/dendrite/setup/config"
|
||||
|
@ -59,7 +58,7 @@ func Setup(
|
|||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.InvalidUsername("Username was invalid"),
|
||||
JSON: spec.InvalidUsername("Username was invalid"),
|
||||
}
|
||||
}
|
||||
return SendTransactionToRelay(
|
||||
|
@ -84,7 +83,7 @@ func Setup(
|
|||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.InvalidUsername("Username was invalid"),
|
||||
JSON: spec.InvalidUsername("Username was invalid"),
|
||||
}
|
||||
}
|
||||
return GetTransactionFromRelay(httpReq, request, relayAPI, *userID)
|
||||
|
|
|
@ -18,7 +18,6 @@ import (
|
|||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
"github.com/matrix-org/dendrite/relayapi/api"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/gomatrixserverlib/fclient"
|
||||
|
@ -43,7 +42,7 @@ func SendTransactionToRelay(
|
|||
logrus.Info("The request body could not be decoded into valid JSON." + err.Error())
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.NotJSON("The request body could not be decoded into valid JSON." + err.Error()),
|
||||
JSON: spec.NotJSON("The request body could not be decoded into valid JSON." + err.Error()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +51,7 @@ func SendTransactionToRelay(
|
|||
if len(txnEvents.PDUs) > 50 || len(txnEvents.EDUs) > 100 {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.BadJSON("max 50 pdus / 100 edus"),
|
||||
JSON: spec.BadJSON("max 50 pdus / 100 edus"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +68,7 @@ func SendTransactionToRelay(
|
|||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: jsonerror.BadJSON("could not store the transaction for forwarding"),
|
||||
JSON: spec.BadJSON("could not store the transaction for forwarding"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue