Update error check to use actual error

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>
This commit is contained in:
Till Faelligen 2020-11-17 17:22:44 +01:00
parent 3e8c91ff8b
commit 44260bba15
2 changed files with 6 additions and 3 deletions

View file

@ -16,8 +16,8 @@ package perform
import (
"context"
"errors"
"fmt"
"strings"
federationSenderAPI "github.com/matrix-org/dendrite/federationsender/api"
"github.com/matrix-org/dendrite/internal/config"
@ -160,8 +160,10 @@ func (r *Inviter) PerformInvite(
Code: api.PerformErrorNotAllowed,
}
if strings.Contains(err.Error(), "value is outside of safe range") {
log.Debug("setting error to PerformErrCanonicalJSON")
// Ensure we send the correct http code if the json is invalid for
// room version 6.
if req.RoomVersion == gomatrixserverlib.RoomVersionV6 &&
errors.Is(err, gomatrixserverlib.ErrCanonicalJSON) {
res.Error.Code = api.PerformErrCanonicalJSON
}

View file

@ -496,3 +496,4 @@ Forgetting room does not show up in v2 /sync
Can forget room you've been kicked from
Can re-join room if re-invited
/whois
Outbound federation rejects invite response which include invalid JSON for room version 6