BREAKING: update mautrix to 0.15.x

This commit is contained in:
Aine
2023-06-01 14:32:20 +00:00
parent a6b20a75ab
commit 2bdb8ca635
222 changed files with 7851 additions and 23986 deletions

View File

@@ -11,6 +11,8 @@ import (
"errors"
"fmt"
"net/http"
"golang.org/x/exp/maps"
)
// Common error codes from https://matrix.org/docs/spec/client_server/latest#api-standards
@@ -60,6 +62,11 @@ var (
MIncompatibleRoomVersion = RespError{ErrCode: "M_INCOMPATIBLE_ROOM_VERSION"}
// The client specified a parameter that has the wrong value.
MInvalidParam = RespError{ErrCode: "M_INVALID_PARAM"}
MURLNotSet = RespError{ErrCode: "M_URL_NOT_SET"}
MBadStatus = RespError{ErrCode: "M_BAD_STATUS"}
MConnectionTimeout = RespError{ErrCode: "M_CONNECTION_TIMEOUT"}
MConnectionFailed = RespError{ErrCode: "M_CONNECTION_FAILED"}
)
// HTTPError An HTTP Error response, which may wrap an underlying native Go Error.
@@ -124,12 +131,13 @@ func (e *RespError) UnmarshalJSON(data []byte) error {
}
func (e *RespError) MarshalJSON() ([]byte, error) {
if e.ExtraData == nil {
e.ExtraData = make(map[string]interface{})
data := maps.Clone(e.ExtraData)
if data == nil {
data = make(map[string]any)
}
e.ExtraData["errcode"] = e.ErrCode
e.ExtraData["error"] = e.Err
return json.Marshal(&e.ExtraData)
data["errcode"] = e.ErrCode
data["error"] = e.Err
return json.Marshal(data)
}
// Error returns the errcode and error message.