Try to generate HTTP error for gomatrixserverlib.NotAllowed

This commit is contained in:
Neil Alexander 2021-11-10 13:32:48 +00:00
parent a28297c39d
commit 2e9a727620
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"time"
"github.com/matrix-org/dendrite/federationsender/api"
@ -115,6 +116,12 @@ func (r *FederationSenderInternalAPI) PerformJoin(
// Clear the wrapped error, else serialising to JSON (in polylith mode) will fail
httpErr.WrappedError = nil
response.LastError = &httpErr
} else if na, ok := lastErr.(*gomatrixserverlib.NotAllowed); ok {
response.LastError = &gomatrix.HTTPError{
Code: http.StatusForbidden,
WrappedError: na,
Message: na.Message,
}
} else {
response.LastError = &gomatrix.HTTPError{
Code: 0,