mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 00:03:09 -06:00
Solve Outbound federation rejects invite response which include invalid
JSON for room version 6
This commit is contained in:
parent
8ce740d949
commit
50eed11a80
|
|
@ -56,6 +56,11 @@ func (p *PerformError) JSONResponse() util.JSONResponse {
|
|||
// TODO: Should we assert this is in fact JSON? E.g gjson parse?
|
||||
JSON: json.RawMessage(p.Msg),
|
||||
}
|
||||
case PerformErrCanonicalJSON:
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.BadJSON(p.Msg),
|
||||
}
|
||||
default:
|
||||
return util.ErrorResponse(p)
|
||||
}
|
||||
|
|
@ -72,6 +77,8 @@ const (
|
|||
PerformErrorNoOperation PerformErrorCode = 4
|
||||
// PerformErrRemote means that the request failed and the PerformError.Msg is the raw remote JSON error response
|
||||
PerformErrRemote PerformErrorCode = 5
|
||||
// PerformErrCanonicalJSON means that the request failed due to invalid json
|
||||
PerformErrCanonicalJSON PerformErrorCode = 6
|
||||
)
|
||||
|
||||
type PerformJoinRequest struct {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package perform
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
federationSenderAPI "github.com/matrix-org/dendrite/federationsender/api"
|
||||
"github.com/matrix-org/dendrite/internal/config"
|
||||
|
|
@ -158,6 +159,12 @@ func (r *Inviter) PerformInvite(
|
|||
Msg: err.Error(),
|
||||
Code: api.PerformErrorNotAllowed,
|
||||
}
|
||||
|
||||
if strings.Contains(err.Error(), "value is outside of safe range") {
|
||||
log.Debug("setting error to PerformErrCanonicalJSON")
|
||||
res.Error.Code = api.PerformErrCanonicalJSON
|
||||
}
|
||||
|
||||
log.WithError(err).WithField("event_id", event.EventID()).Error("r.FSAPI.PerformInvite failed")
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue