mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 23:03:10 -06:00
configure jsoniter to be compatible with encoding/json
By default jsoniter sorts json keys non-reproducibly
This commit is contained in:
parent
857a4fe61c
commit
431a5ea431
|
|
@ -76,7 +76,7 @@ func (s *OutputRoomEventConsumer) Start() error {
|
|||
func (s *OutputRoomEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
||||
// Parse out the event JSON
|
||||
var output api.OutputEvent
|
||||
if err := json.Unmarshal(msg.Value, &output); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(msg.Value, &output); err != nil {
|
||||
// If the message was invalid, log it and move on to the next message in the stream
|
||||
log.WithError(err).Errorf("roomserver output log: message parse failure")
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ func retrieveEvents(eventRows *sql.Rows, limit int) (events []gomatrixserverlib.
|
|||
}
|
||||
|
||||
// Unmarshal eventJSON
|
||||
if err = json.Unmarshal(eventJSON, &event); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(eventJSON, &event); err != nil {
|
||||
return nil, 0, 0, false, err
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ func (s *eventsStatements) insertEvent(
|
|||
event *gomatrixserverlib.HeaderedEvent,
|
||||
) (err error) {
|
||||
// Convert event to JSON before inserting
|
||||
eventJSON, err := json.Marshal(event)
|
||||
eventJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ func retrieveEvents(eventRows *sql.Rows, limit int) (events []gomatrixserverlib.
|
|||
}
|
||||
|
||||
// Unmarshal eventJSON
|
||||
if err = json.Unmarshal(eventJSON, &event); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(eventJSON, &event); err != nil {
|
||||
return nil, 0, 0, false, err
|
||||
}
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ func (s *eventsStatements) insertEvent(
|
|||
event *gomatrixserverlib.HeaderedEvent,
|
||||
) (err error) {
|
||||
// Convert event to JSON before inserting
|
||||
eventJSON, err := json.Marshal(event)
|
||||
eventJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ func createTransaction(
|
|||
Events: ev,
|
||||
}
|
||||
|
||||
transactionJSON, err = json.Marshal(transaction)
|
||||
transactionJSON, err = json.ConfigCompatibleWithStandardLibrary.Marshal(transaction)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,19 +182,19 @@ func (u *UserInteractive) NewSession() *util.JSONResponse {
|
|||
// standard challenge response.
|
||||
func (u *UserInteractive) ResponseWithChallenge(sessionID string, response interface{}) *util.JSONResponse {
|
||||
mixedObjects := make(map[string]interface{})
|
||||
b, err := json.Marshal(response)
|
||||
b, err := json.ConfigCompatibleWithStandardLibrary.Marshal(response)
|
||||
if err != nil {
|
||||
ise := jsonerror.InternalServerError()
|
||||
return &ise
|
||||
}
|
||||
_ = json.Unmarshal(b, &mixedObjects)
|
||||
_ = json.ConfigCompatibleWithStandardLibrary.Unmarshal(b, &mixedObjects)
|
||||
challenge := u.Challenge(sessionID)
|
||||
b, err = json.Marshal(challenge.JSON)
|
||||
b, err = json.ConfigCompatibleWithStandardLibrary.Marshal(challenge.JSON)
|
||||
if err != nil {
|
||||
ise := jsonerror.InternalServerError()
|
||||
return &ise
|
||||
}
|
||||
_ = json.Unmarshal(b, &mixedObjects)
|
||||
_ = json.ConfigCompatibleWithStandardLibrary.Unmarshal(b, &mixedObjects)
|
||||
|
||||
return &util.JSONResponse{
|
||||
Code: 401,
|
||||
|
|
@ -238,7 +238,7 @@ func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte, device *
|
|||
}
|
||||
|
||||
r := loginType.Request()
|
||||
if err := json.Unmarshal([]byte(gjson.GetBytes(bodyBytes, "auth").Raw), r); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(gjson.GetBytes(bodyBytes, "auth").Raw), r); err != nil {
|
||||
return nil, &util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.BadJSON("The request body could not be decoded into valid JSON. " + err.Error()),
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ func UnmarshalJSONRequest(req *http.Request, iface interface{}) *util.JSONRespon
|
|||
}
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(body, iface); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(body, iface); err != nil {
|
||||
// TODO: We may want to suppress the Error() return in production? It's useful when
|
||||
// debugging because an error will be produced for both invalid/malformed JSON AND
|
||||
// valid JSON with incorrect types for values.
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
func TestLimitExceeded(t *testing.T) {
|
||||
e := LimitExceeded("too fast", 5000)
|
||||
jsonBytes, err := json.Marshal(&e)
|
||||
jsonBytes, err := json.ConfigCompatibleWithStandardLibrary.Marshal(&e)
|
||||
if err != nil {
|
||||
t.Fatalf("TestLimitExceeded: Failed to marshal LimitExceeded error. %s", err.Error())
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ func TestLimitExceeded(t *testing.T) {
|
|||
|
||||
func TestForbidden(t *testing.T) {
|
||||
e := Forbidden("you shall not pass")
|
||||
jsonBytes, err := json.Marshal(&e)
|
||||
jsonBytes, err := json.ConfigCompatibleWithStandardLibrary.Marshal(&e)
|
||||
if err != nil {
|
||||
t.Fatalf("TestForbidden: Failed to marshal Forbidden error. %s", err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ func (p *SyncAPIProducer) SendData(userID string, roomID string, dataType string
|
|||
RoomID: roomID,
|
||||
Type: dataType,
|
||||
}
|
||||
value, err := json.Marshal(data)
|
||||
value, err := json.ConfigCompatibleWithStandardLibrary.Marshal(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ func SaveReadMarker(
|
|||
}
|
||||
}
|
||||
|
||||
data, err := json.Marshal(fullyReadEvent{EventID: r.FullyRead})
|
||||
data, err := json.ConfigCompatibleWithStandardLibrary.Marshal(fullyReadEvent{EventID: r.FullyRead})
|
||||
if err != nil {
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func (r createRoomRequest) Validate() *util.JSONResponse {
|
|||
// creation_content map into bytes and then unmarshalling the bytes into
|
||||
// eventutil.CreateContent.
|
||||
|
||||
creationContentBytes, err := json.Marshal(r.CreationContent)
|
||||
creationContentBytes, err := json.ConfigCompatibleWithStandardLibrary.Marshal(r.CreationContent)
|
||||
if err != nil {
|
||||
return &util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
|
|
@ -109,7 +109,7 @@ func (r createRoomRequest) Validate() *util.JSONResponse {
|
|||
}
|
||||
|
||||
var CreationContent gomatrixserverlib.CreateContent
|
||||
err = json.Unmarshal(creationContentBytes, &CreationContent)
|
||||
err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(creationContentBytes, &CreationContent)
|
||||
if err != nil {
|
||||
return &util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func GetMemberships(
|
|||
res.Joined = make(map[string]joinedMember)
|
||||
for _, ev := range queryRes.JoinEvents {
|
||||
var content joinedMember
|
||||
if err := json.Unmarshal(ev.Content, &content); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(ev.Content, &content); err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Error("failed to unmarshal event content")
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ func validateRecaptcha(
|
|||
JSON: jsonerror.Unknown("Error in contacting captcha server" + err.Error()),
|
||||
}
|
||||
}
|
||||
err = json.Unmarshal(body, &r)
|
||||
err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(body, &r)
|
||||
if err != nil {
|
||||
return &util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ func obtainSavedTags(
|
|||
if !ok {
|
||||
return
|
||||
}
|
||||
if err = json.Unmarshal(data, &tags); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(data, &tags); err != nil {
|
||||
return
|
||||
}
|
||||
return tags, nil
|
||||
|
|
@ -198,7 +198,7 @@ func saveTagData(
|
|||
userAPI api.UserInternalAPI,
|
||||
Tag gomatrix.TagContent,
|
||||
) error {
|
||||
newTagData, err := json.Marshal(Tag)
|
||||
newTagData, err := json.ConfigCompatibleWithStandardLibrary.Marshal(Tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func OnIncomingStateRequest(ctx context.Context, device *userapi.Device, rsAPI a
|
|||
for _, ev := range stateRes.StateEvents {
|
||||
if ev.Type() == gomatrixserverlib.MRoomHistoryVisibility {
|
||||
content := map[string]string{}
|
||||
if err := json.Unmarshal(ev.Content(), &content); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(ev.Content(), &content); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("json.Unmarshal for history visibility failed")
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ func OnIncomingStateTypeRequest(
|
|||
for _, ev := range stateRes.StateEvents {
|
||||
if ev.Type() == gomatrixserverlib.MRoomHistoryVisibility {
|
||||
content := map[string]string{}
|
||||
if err := json.Unmarshal(ev.Content(), &content); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(ev.Content(), &content); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("json.Unmarshal for history visibility failed")
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ func checkIDServerSignatures(
|
|||
ctx context.Context, body *MembershipRequest, res *idServerLookupResponse,
|
||||
) error {
|
||||
// Mashall the body so we can give it to VerifyJSON
|
||||
marshalledBody, err := json.Marshal(*res)
|
||||
marshalledBody, err := json.ConfigCompatibleWithStandardLibrary.Marshal(*res)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ func (p *publicRoomsProvider) AdvertiseRooms() error {
|
|||
}
|
||||
advertised := 0
|
||||
for _, room := range ourRooms {
|
||||
if j, err := json.Marshal(room); err == nil {
|
||||
if j, err := json.ConfigCompatibleWithStandardLibrary.Marshal(room); err == nil {
|
||||
if err := p.topic.Publish(context.TODO(), j); err != nil {
|
||||
fmt.Println("Failed to publish public room:", err)
|
||||
} else {
|
||||
|
|
@ -133,7 +133,7 @@ func (p *publicRoomsProvider) FindRooms() {
|
|||
received := discoveredRoom{
|
||||
time: time.Now(),
|
||||
}
|
||||
if err := json.Unmarshal(msg.Data, &received.room); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(msg.Data, &received.room); err != nil {
|
||||
fmt.Println("Unmarshal error:", err)
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ func Setup(instanceName, storageDirectory string) (*Node, error) {
|
|||
if e != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(yggconf), &n.config); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(yggconf), &n.config); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ func main() {
|
|||
bodyBytes = append(bodyBytes, bytes...)
|
||||
}
|
||||
fmt.Println("Done!")
|
||||
if err = json.Unmarshal(bodyBytes, &bodyObj); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(bodyBytes, &bodyObj); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ func writeToRoomServer(input []string, roomserverURL string) error {
|
|||
var err error
|
||||
request.InputRoomEvents = make([]api.InputRoomEvent, len(input))
|
||||
for i := range input {
|
||||
if err = json.Unmarshal([]byte(input[i]), &request.InputRoomEvents[i]); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(input[i]), &request.InputRoomEvents[i]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,13 +101,13 @@ func createTestUser(database, username, token string) error {
|
|||
// Panics if there are any problems.
|
||||
func clientEventJSONForOutputRoomEvent(outputRoomEvent string) string {
|
||||
var out api.OutputEvent
|
||||
if err := json.Unmarshal([]byte(outputRoomEvent), &out); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(outputRoomEvent), &out); err != nil {
|
||||
panic("failed to unmarshal output room event: " + err.Error())
|
||||
}
|
||||
clientEvs := gomatrixserverlib.ToClientEvents([]gomatrixserverlib.Event{
|
||||
out.NewRoomEvent.Event.Event,
|
||||
}, gomatrixserverlib.FormatSync)
|
||||
b, err := json.Marshal(clientEvs[0])
|
||||
b, err := json.ConfigCompatibleWithStandardLibrary.Marshal(clientEvs[0])
|
||||
if err != nil {
|
||||
panic("failed to marshal client event as json: " + err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ func SendToDevice(
|
|||
ctx context.Context, eduAPI EDUServerInputAPI, sender, userID, deviceID, eventType string,
|
||||
message interface{},
|
||||
) error {
|
||||
js, err := json.Marshal(message)
|
||||
js, err := json.ConfigCompatibleWithStandardLibrary.Marshal(message)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ func (t *EDUServerInputAPI) sendTypingEvent(ite *api.InputTypingEvent) error {
|
|||
ote.ExpireTime = &expireTime
|
||||
}
|
||||
|
||||
eventJSON, err := json.Marshal(ote)
|
||||
eventJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(ote)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ func (t *EDUServerInputAPI) sendToDeviceEvent(ise *api.InputSendToDeviceEvent) e
|
|||
SendToDeviceEvent: ise.SendToDeviceEvent,
|
||||
}
|
||||
|
||||
eventJSON, err := json.Marshal(ote)
|
||||
eventJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(ote)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("sendToDevice failed json.Marshal")
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ func GetUserDevices(
|
|||
|
||||
for _, dev := range res.Devices {
|
||||
var key gomatrixserverlib.RespUserDeviceKeys
|
||||
err := json.Unmarshal(dev.DeviceKeys.KeyJSON, &key)
|
||||
err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(dev.DeviceKeys.KeyJSON, &key)
|
||||
if err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Warnf("malformed device key: %s", string(dev.DeviceKeys.KeyJSON))
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ func InviteV2(
|
|||
keys gomatrixserverlib.JSONVerifier,
|
||||
) util.JSONResponse {
|
||||
inviteReq := gomatrixserverlib.InviteV2Request{}
|
||||
err := json.Unmarshal(request.Content(), &inviteReq)
|
||||
err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(request.Content(), &inviteReq)
|
||||
switch err.(type) {
|
||||
case gomatrixserverlib.BadJSONError:
|
||||
return util.JSONResponse{
|
||||
|
|
@ -86,7 +86,7 @@ func InviteV1(
|
|||
}
|
||||
}
|
||||
var strippedState []gomatrixserverlib.InviteV2StrippedState
|
||||
if err := json.Unmarshal(event.Unsigned(), &strippedState); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(event.Unsigned(), &strippedState); err != nil {
|
||||
// just warn, they may not have added any.
|
||||
util.GetLogger(httpReq.Context()).Warnf("failed to extract stripped state from invite event")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ func QueryDeviceKeys(
|
|||
httpReq *http.Request, request *gomatrixserverlib.FederationRequest, keyAPI api.KeyInternalAPI, thisServer gomatrixserverlib.ServerName,
|
||||
) util.JSONResponse {
|
||||
var qkr queryKeysRequest
|
||||
err := json.Unmarshal(request.Content(), &qkr)
|
||||
err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(request.Content(), &qkr)
|
||||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
|
|
@ -87,7 +87,7 @@ func ClaimOneTimeKeys(
|
|||
httpReq *http.Request, request *gomatrixserverlib.FederationRequest, keyAPI api.KeyInternalAPI, thisServer gomatrixserverlib.ServerName,
|
||||
) util.JSONResponse {
|
||||
var cor claimOTKsRequest
|
||||
err := json.Unmarshal(request.Content(), &cor)
|
||||
err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(request.Content(), &cor)
|
||||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
|
|
@ -157,7 +157,7 @@ func localKeys(cfg *config.FederationAPI, validUntil time.Time) (*gomatrixserver
|
|||
}
|
||||
}
|
||||
|
||||
toSign, err := json.Marshal(keys.ServerKeyFields)
|
||||
toSign, err := json.ConfigCompatibleWithStandardLibrary.Marshal(keys.ServerKeyFields)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@ func NotaryKeys(
|
|||
continue
|
||||
}
|
||||
|
||||
j, err := json.Marshal(keys)
|
||||
j, err := json.ConfigCompatibleWithStandardLibrary.Marshal(keys)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to marshal %q response", serverName)
|
||||
return jsonerror.InternalServerError()
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func GetMissingEvents(
|
|||
roomID string,
|
||||
) util.JSONResponse {
|
||||
var gme getMissingEventRequest
|
||||
if err := json.Unmarshal(request.Content(), &gme); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(request.Content(), &gme); err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.NotJSON("The request body could not be decoded into valid JSON. " + err.Error()),
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func Send(
|
|||
EDUs []gomatrixserverlib.EDU `json:"edus"`
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(request.Content(), &txnEvents); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(request.Content(), &txnEvents); err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.NotJSON("The request body could not be decoded into valid JSON. " + err.Error()),
|
||||
|
|
@ -134,7 +134,7 @@ func (t *txnReq) processTransaction(ctx context.Context) (*gomatrixserverlib.Res
|
|||
var header struct {
|
||||
RoomID string `json:"room_id"`
|
||||
}
|
||||
if err := json.Unmarshal(pdu, &header); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(pdu, &header); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Warn("Transaction: Failed to extract room ID from event")
|
||||
// We don't know the event ID at this point so we can't return the
|
||||
// failure in the PDU results
|
||||
|
|
@ -290,7 +290,7 @@ func (t *txnReq) processEDUs(ctx context.Context) {
|
|||
UserID string `json:"user_id"`
|
||||
Typing bool `json:"typing"`
|
||||
}
|
||||
if err := json.Unmarshal(e.Content, &typingPayload); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(e.Content, &typingPayload); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("Failed to unmarshal typing event")
|
||||
continue
|
||||
}
|
||||
|
|
@ -300,7 +300,7 @@ func (t *txnReq) processEDUs(ctx context.Context) {
|
|||
case gomatrixserverlib.MDirectToDevice:
|
||||
// https://matrix.org/docs/spec/server_server/r0.1.3#m-direct-to-device-schema
|
||||
var directPayload gomatrixserverlib.ToDeviceMessage
|
||||
if err := json.Unmarshal(e.Content, &directPayload); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(e.Content, &directPayload); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("Failed to unmarshal send-to-device events")
|
||||
continue
|
||||
}
|
||||
|
|
@ -326,7 +326,7 @@ func (t *txnReq) processEDUs(ctx context.Context) {
|
|||
|
||||
func (t *txnReq) processDeviceListUpdate(ctx context.Context, e gomatrixserverlib.EDU) {
|
||||
var payload gomatrixserverlib.DeviceListUpdateEvent
|
||||
if err := json.Unmarshal(e.Content, &payload); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(e.Content, &payload); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("Failed to unmarshal device list update event")
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ func ExchangeThirdPartyInvite(
|
|||
federation *gomatrixserverlib.FederationClient,
|
||||
) util.JSONResponse {
|
||||
var builder gomatrixserverlib.EventBuilder
|
||||
if err := json.Unmarshal(request.Content(), &builder); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(request.Content(), &builder); err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.NotJSON("The request body could not be decoded into valid JSON. " + err.Error()),
|
||||
|
|
@ -368,7 +368,7 @@ func fillDisplayName(
|
|||
builder *gomatrixserverlib.EventBuilder, authEvents gomatrixserverlib.AuthEvents,
|
||||
) error {
|
||||
var content gomatrixserverlib.MemberContent
|
||||
if err := json.Unmarshal(builder.Content, &content); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(builder.Content, &content); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -381,7 +381,7 @@ func fillDisplayName(
|
|||
}
|
||||
|
||||
var thirdPartyInviteContent gomatrixserverlib.ThirdPartyInviteContent
|
||||
if err := json.Unmarshal(thirdPartyInviteEvent.Content(), &thirdPartyInviteContent); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(thirdPartyInviteEvent.Content(), &thirdPartyInviteContent); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ func (t *OutputEDUConsumer) Start() error {
|
|||
func (t *OutputEDUConsumer) onSendToDeviceEvent(msg *sarama.ConsumerMessage) error {
|
||||
// Extract the send-to-device event from msg.
|
||||
var ote api.OutputSendToDeviceEvent
|
||||
if err := json.Unmarshal(msg.Value, &ote); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(msg.Value, &ote); err != nil {
|
||||
log.WithError(err).Errorf("eduserver output log: message parse failed (expected send-to-device)")
|
||||
return nil
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ func (t *OutputEDUConsumer) onSendToDeviceEvent(msg *sarama.ConsumerMessage) err
|
|||
},
|
||||
},
|
||||
}
|
||||
if edu.Content, err = json.Marshal(tdm); err != nil {
|
||||
if edu.Content, err = json.ConfigCompatibleWithStandardLibrary.Marshal(tdm); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ func (t *OutputEDUConsumer) onSendToDeviceEvent(msg *sarama.ConsumerMessage) err
|
|||
func (t *OutputEDUConsumer) onTypingEvent(msg *sarama.ConsumerMessage) error {
|
||||
// Extract the typing event from msg.
|
||||
var ote api.OutputTypingEvent
|
||||
if err := json.Unmarshal(msg.Value, &ote); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(msg.Value, &ote); err != nil {
|
||||
// Skip this msg but continue processing messages.
|
||||
log.WithError(err).Errorf("eduserver output log: message parse failed (expected typing)")
|
||||
return nil
|
||||
|
|
@ -168,7 +168,7 @@ func (t *OutputEDUConsumer) onTypingEvent(msg *sarama.ConsumerMessage) error {
|
|||
}
|
||||
|
||||
edu := &gomatrixserverlib.EDU{Type: ote.Event.Type}
|
||||
if edu.Content, err = json.Marshal(map[string]interface{}{
|
||||
if edu.Content, err = json.ConfigCompatibleWithStandardLibrary.Marshal(map[string]interface{}{
|
||||
"room_id": ote.Event.RoomID,
|
||||
"user_id": ote.Event.UserID,
|
||||
"typing": ote.Event.Typing,
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ func (t *KeyChangeConsumer) Start() error {
|
|||
// key change events topic from the key server.
|
||||
func (t *KeyChangeConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
||||
var m api.DeviceMessage
|
||||
if err := json.Unmarshal(msg.Value, &m); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(msg.Value, &m); err != nil {
|
||||
log.WithError(err).Errorf("failed to read device message from key change topic")
|
||||
return nil
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ func (t *KeyChangeConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
|||
Deleted: len(m.KeyJSON) == 0,
|
||||
Keys: m.KeyJSON,
|
||||
}
|
||||
if edu.Content, err = json.Marshal(event); err != nil {
|
||||
if edu.Content, err = json.ConfigCompatibleWithStandardLibrary.Marshal(event); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ func (s *OutputRoomEventConsumer) Start() error {
|
|||
func (s *OutputRoomEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
||||
// Parse out the event JSON
|
||||
var output api.OutputEvent
|
||||
if err := json.Unmarshal(msg.Value, &output); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(msg.Value, &output); err != nil {
|
||||
// If the message was invalid, log it and move on to the next message in the stream
|
||||
log.WithError(err).Errorf("roomserver output log: message parse failure")
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ func (oqs *OutgoingQueues) SendEvent(
|
|||
"destinations": len(destmap), "event": ev.EventID(),
|
||||
}).Infof("Sending event")
|
||||
|
||||
headeredJSON, err := json.Marshal(ev)
|
||||
headeredJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(ev)
|
||||
if err != nil {
|
||||
return fmt.Errorf("json.Marshal: %w", err)
|
||||
}
|
||||
|
|
@ -225,7 +225,7 @@ func (oqs *OutgoingQueues) SendEDU(
|
|||
"destinations": len(destmap), "edu_type": e.Type,
|
||||
}).Info("Sending EDU event")
|
||||
|
||||
ephemeralJSON, err := json.Marshal(e)
|
||||
ephemeralJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(e)
|
||||
if err != nil {
|
||||
return fmt.Errorf("json.Marshal: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ func (e *Receipt) Empty() bool {
|
|||
}
|
||||
|
||||
func (e *Receipt) String() string {
|
||||
j, _ := json.Marshal(e.nids)
|
||||
j, _ := json.ConfigCompatibleWithStandardLibrary.Marshal(e.nids)
|
||||
return string(j)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ func (d *Database) GetNextTransactionEDUs(
|
|||
|
||||
for _, blob := range blobs {
|
||||
var event gomatrixserverlib.EDU
|
||||
if err := json.Unmarshal(blob, &event); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(blob, &event); err != nil {
|
||||
return fmt.Errorf("json.Unmarshal: %w", err)
|
||||
}
|
||||
edus = append(edus, &event)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ func (d *Database) GetNextTransactionPDUs(
|
|||
|
||||
for _, blob := range blobs {
|
||||
var event gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(blob, &event); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(blob, &event); err != nil {
|
||||
return fmt.Errorf("json.Unmarshal: %w", err)
|
||||
}
|
||||
events = append(events, &event)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ func PostJSON(
|
|||
ctx context.Context, span opentracing.Span, httpClient *http.Client,
|
||||
apiURL string, request, response interface{},
|
||||
) error {
|
||||
jsonBytes, err := json.Marshal(request)
|
||||
jsonBytes, err := json.ConfigCompatibleWithStandardLibrary.Marshal(request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ func (u *DeviceListUpdater) updateDeviceList(res *gomatrixserverlib.RespUserDevi
|
|||
keys := make([]api.DeviceMessage, len(res.Devices))
|
||||
existingKeys := make([]api.DeviceMessage, len(res.Devices))
|
||||
for i, device := range res.Devices {
|
||||
keyJSON, err := json.Marshal(device.Keys)
|
||||
keyJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(device.Keys)
|
||||
if err != nil {
|
||||
util.GetLogger(ctx).WithField("keys", device.Keys).Error("failed to marshal keys, skipping device")
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ func (a *KeyInternalAPI) claimRemoteKeys(
|
|||
for deviceID, nest2 := range nest {
|
||||
res.OneTimeKeys[userID][deviceID] = make(map[string]json.RawMessage)
|
||||
for keyIDWithAlgo, otk := range nest2 {
|
||||
keyJSON, err := json.Marshal(otk)
|
||||
keyJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(otk)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
|
@ -338,7 +338,7 @@ func (a *KeyInternalAPI) queryRemoteKeys(
|
|||
for userID, nest := range result.DeviceKeys {
|
||||
res.DeviceKeys[userID] = make(map[string]json.RawMessage)
|
||||
for deviceID, deviceKey := range nest {
|
||||
keyJSON, err := json.Marshal(deviceKey)
|
||||
keyJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(deviceKey)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ func (p *KeyChange) ProduceKeyChanges(keys []api.DeviceMessage) error {
|
|||
for _, key := range keys {
|
||||
var m sarama.ProducerMessage
|
||||
|
||||
value, err := json.Marshal(key)
|
||||
value, err := json.ConfigCompatibleWithStandardLibrary.Marshal(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,12 +147,12 @@ func Download(
|
|||
|
||||
func (r *downloadRequest) jsonErrorResponse(w http.ResponseWriter, res util.JSONResponse) {
|
||||
// Marshal JSON response into raw bytes to send as the HTTP body
|
||||
resBytes, err := json.Marshal(res.JSON)
|
||||
resBytes, err := json.ConfigCompatibleWithStandardLibrary.Marshal(res.JSON)
|
||||
if err != nil {
|
||||
r.Logger.WithError(err).Error("Failed to marshal JSONResponse")
|
||||
// this should never fail to be marshalled so drop err to the floor
|
||||
res = util.MessageResponse(http.StatusNotFound, "Download request failed: "+err.Error())
|
||||
resBytes, _ = json.Marshal(res.JSON)
|
||||
resBytes, _ = json.ConfigCompatibleWithStandardLibrary.Marshal(res.JSON)
|
||||
}
|
||||
|
||||
// Set status code and write the body
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ func compileACLRegex(orig string) (*regexp.Regexp, error) {
|
|||
|
||||
func (s *ServerACLs) OnServerACLUpdate(state *gomatrixserverlib.Event) {
|
||||
acls := &serverACL{}
|
||||
if err := json.Unmarshal(state.Content(), &acls.ServerACL); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(state.Content(), &acls.ServerACL); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to unmarshal state content for server ACLs")
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ func (t *RoomserverInternalAPITrace) QueryServerBannedFromRoom(ctx context.Conte
|
|||
}
|
||||
|
||||
func js(thing interface{}) string {
|
||||
b, err := json.Marshal(thing)
|
||||
b, err := json.ConfigCompatibleWithStandardLibrary.Marshal(thing)
|
||||
if err != nil {
|
||||
return fmt.Sprintf("Marshal error:%s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,12 +352,12 @@ func (r *QueryBulkStateContentResponse) MarshalJSON() ([]byte, error) {
|
|||
se[fmt.Sprintf("%s\x1F%s\x1F%s", roomID, tuple.EventType, tuple.StateKey)] = event
|
||||
}
|
||||
}
|
||||
return json.Marshal(se)
|
||||
return json.ConfigCompatibleWithStandardLibrary.Marshal(se)
|
||||
}
|
||||
|
||||
func (r *QueryBulkStateContentResponse) UnmarshalJSON(data []byte) error {
|
||||
wireFormat := make(map[string]string)
|
||||
err := json.Unmarshal(data, &wireFormat)
|
||||
err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(data, &wireFormat)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -383,12 +383,12 @@ func (r *QueryCurrentStateResponse) MarshalJSON() ([]byte, error) {
|
|||
// use 0x1F (unit separator) as the delimiter between type/state key,
|
||||
se[fmt.Sprintf("%s\x1F%s", k.EventType, k.StateKey)] = v
|
||||
}
|
||||
return json.Marshal(se)
|
||||
return json.ConfigCompatibleWithStandardLibrary.Marshal(se)
|
||||
}
|
||||
|
||||
func (r *QueryCurrentStateResponse) UnmarshalJSON(data []byte) error {
|
||||
res := make(map[string]*gomatrixserverlib.HeaderedEvent)
|
||||
err := json.Unmarshal(data, &res)
|
||||
err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(data, &res)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ func HistoryVisibilityForRoom(authEvents []gomatrixserverlib.Event) string {
|
|||
content := struct {
|
||||
HistoryVisibility string `json:"history_visibility"`
|
||||
}{}
|
||||
if err := json.Unmarshal(ev.Content(), &content); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(ev.Content(), &content); err != nil {
|
||||
break // value is not understood
|
||||
}
|
||||
for _, s := range knownStates {
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ func (r *RoomserverInternalAPI) sendUpdatedAliasesEvent(
|
|||
return err
|
||||
}
|
||||
content := roomAliasesContent{Aliases: aliases}
|
||||
rawContent, err := json.Marshal(content)
|
||||
rawContent, err := json.ConfigCompatibleWithStandardLibrary.Marshal(content)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func (w *inputWorker) start() {
|
|||
func (r *Inputer) WriteOutputEvents(roomID string, updates []api.OutputEvent) error {
|
||||
messages := make([]*sarama.ProducerMessage, len(updates))
|
||||
for i := range updates {
|
||||
value, err := json.Marshal(updates[i])
|
||||
value, err := json.ConfigCompatibleWithStandardLibrary.Marshal(updates[i])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ func (r *Peeker) performPeekRoomByID(
|
|||
ev, _ := r.DB.GetStateEvent(ctx, roomID, "m.room.history_visibility", "")
|
||||
if ev != nil {
|
||||
content := map[string]string{}
|
||||
if err = json.Unmarshal(ev.Content(), &content); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(ev.Content(), &content); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("json.Unmarshal for history visibility failed")
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ func (db *getEventDB) addFakeEvent(eventID string, authIDs []string) error {
|
|||
"auth_events": authEvents,
|
||||
}
|
||||
|
||||
eventJSON, err := json.Marshal(&builder)
|
||||
eventJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(&builder)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ func (p *dummyProducer) SendMessage(msg *sarama.ProducerMessage) (partition int3
|
|||
b := json.RawMessage(be)
|
||||
fmt.Println("SENDING >>>>>>>> ", string(b))
|
||||
var out api.OutputEvent
|
||||
err = json.Unmarshal(b, &out)
|
||||
err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(b, &out)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -603,7 +603,7 @@ func extractRoomVersionFromCreateEvent(event gomatrixserverlib.Event) (
|
|||
var createContent gomatrixserverlib.CreateContent
|
||||
// The m.room.create event contains an optional "room_version" key in
|
||||
// the event content, so we need to unmarshal that first.
|
||||
if err = json.Unmarshal(event.Content(), &createContent); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(event.Content(), &createContent); err != nil {
|
||||
return gomatrixserverlib.RoomVersion(""), err
|
||||
}
|
||||
// A room version was specified in the event content?
|
||||
|
|
|
|||
|
|
@ -489,6 +489,6 @@ func (s *eventStatements) SelectRoomNIDForEventNID(
|
|||
}
|
||||
|
||||
func eventNIDsAsArray(eventNIDs []types.EventNID) string {
|
||||
b, _ := json.Marshal(eventNIDs)
|
||||
b, _ := json.ConfigCompatibleWithStandardLibrary.Marshal(eventNIDs)
|
||||
return string(b)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ func (s *roomStatements) SelectRoomInfo(ctx context.Context, roomID string) (*ty
|
|||
return nil, err
|
||||
}
|
||||
var latestNIDs []int64
|
||||
if err = json.Unmarshal([]byte(latestNIDsJSON), &latestNIDs); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(latestNIDsJSON), &latestNIDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
info.IsStub = len(latestNIDs) == 0
|
||||
|
|
@ -181,7 +181,7 @@ func (s *roomStatements) SelectLatestEventNIDs(
|
|||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if err := json.Unmarshal([]byte(nidsJSON), &eventNIDs); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(nidsJSON), &eventNIDs); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return eventNIDs, types.StateSnapshotNID(stateSnapshotNID), nil
|
||||
|
|
@ -199,7 +199,7 @@ func (s *roomStatements) SelectLatestEventsNIDsForUpdate(
|
|||
if err != nil {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
if err := json.Unmarshal([]byte(nidsJSON), &eventNIDs); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(nidsJSON), &eventNIDs); err != nil {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
return eventNIDs, types.EventNID(lastEventSentNID), types.StateSnapshotNID(stateSnapshotNID), nil
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func NewSqliteStateSnapshotTable(db *sql.DB) (tables.StateSnapshot, error) {
|
|||
func (s *stateSnapshotStatements) InsertState(
|
||||
ctx context.Context, txn *sql.Tx, roomNID types.RoomNID, stateBlockNIDs []types.StateBlockNID,
|
||||
) (stateNID types.StateSnapshotNID, err error) {
|
||||
stateBlockNIDsJSON, err := json.Marshal(stateBlockNIDs)
|
||||
stateBlockNIDsJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(stateBlockNIDs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ func (s *stateSnapshotStatements) BulkSelectStateBlockNIDs(
|
|||
if err := rows.Scan(&result.StateSnapshotNID, &stateBlockNIDsJSON); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := json.Unmarshal([]byte(stateBlockNIDsJSON), &result.StateBlockNIDs); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(stateBlockNIDsJSON), &result.StateBlockNIDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ func (s *OutputClientDataConsumer) Start() error {
|
|||
func (s *OutputClientDataConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
||||
// Parse out the event JSON
|
||||
var output eventutil.AccountData
|
||||
if err := json.Unmarshal(msg.Value, &output); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(msg.Value, &output); err != nil {
|
||||
// If the message was invalid, log it and move on to the next message in the stream
|
||||
log.WithError(err).Errorf("client API server output log: message parse failure")
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func (s *OutputSendToDeviceEventConsumer) Start() error {
|
|||
|
||||
func (s *OutputSendToDeviceEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
||||
var output api.OutputSendToDeviceEvent
|
||||
if err := json.Unmarshal(msg.Value, &output); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(msg.Value, &output); err != nil {
|
||||
// If the message was invalid, log it and move on to the next message in the stream
|
||||
log.WithError(err).Errorf("EDU server output log: message parse failure")
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ func (s *OutputTypingEventConsumer) Start() error {
|
|||
|
||||
func (s *OutputTypingEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
||||
var output api.OutputTypingEvent
|
||||
if err := json.Unmarshal(msg.Value, &output); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(msg.Value, &output); err != nil {
|
||||
// If the message was invalid, log it and move on to the next message in the stream
|
||||
log.WithError(err).Errorf("EDU server output log: message parse failure")
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func (s *OutputKeyChangeEventConsumer) onMessage(msg *sarama.ConsumerMessage) er
|
|||
defer s.updateOffset(msg)
|
||||
|
||||
var output api.DeviceMessage
|
||||
if err := json.Unmarshal(msg.Value, &output); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(msg.Value, &output); err != nil {
|
||||
// If the message was invalid, log it and move on to the next message in the stream
|
||||
log.WithError(err).Error("syncapi: failed to unmarshal key change event from key server")
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ func (s *OutputRoomEventConsumer) Start() error {
|
|||
func (s *OutputRoomEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
||||
// Parse out the event JSON
|
||||
var output api.OutputEvent
|
||||
if err := json.Unmarshal(msg.Value, &output); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(msg.Value, &output); err != nil {
|
||||
// If the message was invalid, log it and move on to the next message in the stream
|
||||
log.WithError(err).Errorf("roomserver output log: message parse failure")
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ func PutFilter(
|
|||
}
|
||||
}
|
||||
|
||||
if err = json.Unmarshal(body, &filter); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(body, &filter); err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.BadJSON("The request body could not be decoded into valid JSON. " + err.Error()),
|
||||
|
|
|
|||
|
|
@ -237,12 +237,12 @@ func (s *currentRoomStateStatements) UpsertRoomState(
|
|||
// Parse content as JSON and search for an "url" key
|
||||
containsURL := false
|
||||
var content map[string]interface{}
|
||||
if json.Unmarshal(event.Content(), &content) != nil {
|
||||
if json.ConfigCompatibleWithStandardLibrary.Unmarshal(event.Content(), &content) != nil {
|
||||
// Set containsURL to true if url is present
|
||||
_, containsURL = content["url"]
|
||||
}
|
||||
|
||||
headeredJSON, err := json.Marshal(event)
|
||||
headeredJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -285,7 +285,7 @@ func rowsToEvents(rows *sql.Rows) ([]gomatrixserverlib.HeaderedEvent, error) {
|
|||
}
|
||||
// TODO: Handle redacted events
|
||||
var ev gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(eventBytes, &ev); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(eventBytes, &ev); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, ev)
|
||||
|
|
@ -306,7 +306,7 @@ func (s *currentRoomStateStatements) SelectStateEvent(
|
|||
return nil, err
|
||||
}
|
||||
var ev gomatrixserverlib.HeaderedEvent
|
||||
if err = json.Unmarshal(res, &ev); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(res, &ev); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ev, err
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func (s *filterStatements) SelectFilter(
|
|||
|
||||
// Unmarshal JSON into Filter struct
|
||||
var filter gomatrixserverlib.Filter
|
||||
if err = json.Unmarshal(filterData, &filter); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(filterData, &filter); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &filter, nil
|
||||
|
|
@ -97,7 +97,7 @@ func (s *filterStatements) InsertFilter(
|
|||
var existingFilterID string
|
||||
|
||||
// Serialise json
|
||||
filterJSON, err := json.Marshal(filter)
|
||||
filterJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(filter)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ func (s *inviteEventsStatements) InsertInviteEvent(
|
|||
ctx context.Context, txn *sql.Tx, inviteEvent gomatrixserverlib.HeaderedEvent,
|
||||
) (streamPos types.StreamPosition, err error) {
|
||||
var headeredJSON []byte
|
||||
headeredJSON, err = json.Marshal(inviteEvent)
|
||||
headeredJSON, err = json.ConfigCompatibleWithStandardLibrary.Marshal(inviteEvent)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ func (s *inviteEventsStatements) SelectInviteEventsInRange(
|
|||
}
|
||||
|
||||
var event gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(eventJSON, &event); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(eventJSON, &event); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ func NewPostgresEventsTable(db *sql.DB) (tables.Events, error) {
|
|||
}
|
||||
|
||||
func (s *outputRoomEventsStatements) UpdateEventJSON(ctx context.Context, event *gomatrixserverlib.HeaderedEvent) error {
|
||||
headeredJSON, err := json.Marshal(event)
|
||||
headeredJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -232,7 +232,7 @@ func (s *outputRoomEventsStatements) SelectStateInRange(
|
|||
|
||||
// TODO: Handle redacted events
|
||||
var ev gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(eventBytes, &ev); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(eventBytes, &ev); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
needSet := stateNeeded[ev.RoomID()]
|
||||
|
|
@ -289,13 +289,13 @@ func (s *outputRoomEventsStatements) InsertEvent(
|
|||
// Parse content as JSON and search for an "url" key
|
||||
containsURL := false
|
||||
var content map[string]interface{}
|
||||
if json.Unmarshal(event.Content(), &content) != nil {
|
||||
if json.ConfigCompatibleWithStandardLibrary.Unmarshal(event.Content(), &content) != nil {
|
||||
// Set containsURL to true if url is present
|
||||
_, containsURL = content["url"]
|
||||
}
|
||||
|
||||
var headeredJSON []byte
|
||||
headeredJSON, err = json.Marshal(event)
|
||||
headeredJSON, err = json.ConfigCompatibleWithStandardLibrary.Marshal(event)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -426,7 +426,7 @@ func rowsToStreamEvents(rows *sql.Rows) ([]types.StreamEvent, error) {
|
|||
}
|
||||
// TODO: Handle redacted events
|
||||
var ev gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(eventBytes, &ev); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(eventBytes, &ev); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ func (s *sendToDeviceStatements) SelectSendToDeviceMessages(
|
|||
UserID: userID,
|
||||
DeviceID: deviceID,
|
||||
}
|
||||
if err = json.Unmarshal([]byte(content), &event.SendToDeviceEvent); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(content), &event.SendToDeviceEvent); err != nil {
|
||||
return
|
||||
}
|
||||
if sentByToken != nil {
|
||||
|
|
|
|||
|
|
@ -547,7 +547,7 @@ func (d *Database) addTypingDeltaToResponse(
|
|||
ev := gomatrixserverlib.ClientEvent{
|
||||
Type: gomatrixserverlib.MTyping,
|
||||
}
|
||||
ev.Content, err = json.Marshal(map[string]interface{}{
|
||||
ev.Content, err = json.ConfigCompatibleWithStandardLibrary.Marshal(map[string]interface{}{
|
||||
"user_ids": typingUsers,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -1281,7 +1281,7 @@ func (d *Database) SendToDeviceUpdatesWaiting(
|
|||
func (d *Database) StoreNewSendForDeviceMessage(
|
||||
ctx context.Context, streamPos types.StreamPosition, userID, deviceID string, event gomatrixserverlib.SendToDeviceEvent,
|
||||
) (types.StreamPosition, error) {
|
||||
j, err := json.Marshal(event)
|
||||
j, err := json.ConfigCompatibleWithStandardLibrary.Marshal(event)
|
||||
if err != nil {
|
||||
return streamPos, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,12 +226,12 @@ func (s *currentRoomStateStatements) UpsertRoomState(
|
|||
// Parse content as JSON and search for an "url" key
|
||||
containsURL := false
|
||||
var content map[string]interface{}
|
||||
if json.Unmarshal(event.Content(), &content) != nil {
|
||||
if json.ConfigCompatibleWithStandardLibrary.Unmarshal(event.Content(), &content) != nil {
|
||||
// Set containsURL to true if url is present
|
||||
_, containsURL = content["url"]
|
||||
}
|
||||
|
||||
headeredJSON, err := json.Marshal(event)
|
||||
headeredJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -296,7 +296,7 @@ func rowsToEvents(rows *sql.Rows) ([]gomatrixserverlib.HeaderedEvent, error) {
|
|||
}
|
||||
// TODO: Handle redacted events
|
||||
var ev gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(eventBytes, &ev); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(eventBytes, &ev); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, ev)
|
||||
|
|
@ -317,7 +317,7 @@ func (s *currentRoomStateStatements) SelectStateEvent(
|
|||
return nil, err
|
||||
}
|
||||
var ev gomatrixserverlib.HeaderedEvent
|
||||
if err = json.Unmarshal(res, &ev); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(res, &ev); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ev, err
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ func (s *filterStatements) SelectFilter(
|
|||
|
||||
// Unmarshal JSON into Filter struct
|
||||
var filter gomatrixserverlib.Filter
|
||||
if err = json.Unmarshal(filterData, &filter); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal(filterData, &filter); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &filter, nil
|
||||
|
|
@ -101,7 +101,7 @@ func (s *filterStatements) InsertFilter(
|
|||
var existingFilterID string
|
||||
|
||||
// Serialise json
|
||||
filterJSON, err := json.Marshal(filter)
|
||||
filterJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(filter)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func (s *inviteEventsStatements) InsertInviteEvent(
|
|||
}
|
||||
|
||||
var headeredJSON []byte
|
||||
headeredJSON, err = json.Marshal(inviteEvent)
|
||||
headeredJSON, err = json.ConfigCompatibleWithStandardLibrary.Marshal(inviteEvent)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ func (s *inviteEventsStatements) SelectInviteEventsInRange(
|
|||
}
|
||||
|
||||
var event gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(eventJSON, &event); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(eventJSON, &event); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if deleted {
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ func NewSqliteEventsTable(db *sql.DB, streamID *streamIDStatements) (tables.Even
|
|||
}
|
||||
|
||||
func (s *outputRoomEventsStatements) UpdateEventJSON(ctx context.Context, event *gomatrixserverlib.HeaderedEvent) error {
|
||||
headeredJSON, err := json.Marshal(event)
|
||||
headeredJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -231,7 +231,7 @@ func (s *outputRoomEventsStatements) SelectStateInRange(
|
|||
|
||||
// TODO: Handle redacted events
|
||||
var ev gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(eventBytes, &ev); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(eventBytes, &ev); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
needSet := stateNeeded[ev.RoomID()]
|
||||
|
|
@ -288,22 +288,22 @@ func (s *outputRoomEventsStatements) InsertEvent(
|
|||
// Parse content as JSON and search for an "url" key
|
||||
containsURL := false
|
||||
var content map[string]interface{}
|
||||
if json.Unmarshal(event.Content(), &content) != nil {
|
||||
if json.ConfigCompatibleWithStandardLibrary.Unmarshal(event.Content(), &content) != nil {
|
||||
// Set containsURL to true if url is present
|
||||
_, containsURL = content["url"]
|
||||
}
|
||||
|
||||
var headeredJSON []byte
|
||||
headeredJSON, err := json.Marshal(event)
|
||||
headeredJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(event)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
addStateJSON, err := json.Marshal(addState)
|
||||
addStateJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(addState)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
removeStateJSON, err := json.Marshal(removeState)
|
||||
removeStateJSON, err := json.ConfigCompatibleWithStandardLibrary.Marshal(removeState)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
|
@ -441,7 +441,7 @@ func rowsToStreamEvents(rows *sql.Rows) ([]types.StreamEvent, error) {
|
|||
}
|
||||
// TODO: Handle redacted events
|
||||
var ev gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(eventBytes, &ev); err != nil {
|
||||
if err := json.ConfigCompatibleWithStandardLibrary.Unmarshal(eventBytes, &ev); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
@ -464,12 +464,12 @@ func rowsToStreamEvents(rows *sql.Rows) ([]types.StreamEvent, error) {
|
|||
|
||||
func unmarshalStateIDs(addIDsJSON, delIDsJSON string) (addIDs []string, delIDs []string, err error) {
|
||||
if len(addIDsJSON) > 0 {
|
||||
if err = json.Unmarshal([]byte(addIDsJSON), &addIDs); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(addIDsJSON), &addIDs); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(delIDsJSON) > 0 {
|
||||
if err = json.Unmarshal([]byte(delIDsJSON), &delIDs); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(delIDsJSON), &delIDs); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ func (s *sendToDeviceStatements) SelectSendToDeviceMessages(
|
|||
UserID: userID,
|
||||
DeviceID: deviceID,
|
||||
}
|
||||
if err = json.Unmarshal([]byte(content), &event.SendToDeviceEvent); err != nil {
|
||||
if err = json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(content), &event.SendToDeviceEvent); err != nil {
|
||||
return
|
||||
}
|
||||
if sentByToken != nil {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ var (
|
|||
|
||||
func init() {
|
||||
var err error
|
||||
err = json.Unmarshal([]byte(`{
|
||||
err = json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(`{
|
||||
"_room_version": "1",
|
||||
"type": "m.room.message",
|
||||
"content": {
|
||||
|
|
@ -66,7 +66,7 @@ func init() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = json.Unmarshal([]byte(`{
|
||||
err = json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(`{
|
||||
"_room_version": "1",
|
||||
"type": "m.room.member",
|
||||
"state_key": "`+bob+`",
|
||||
|
|
@ -82,7 +82,7 @@ func init() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = json.Unmarshal([]byte(`{
|
||||
err = json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(`{
|
||||
"_room_version": "1",
|
||||
"type": "m.room.member",
|
||||
"state_key": "`+bob+`",
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ func newSyncRequest(req *http.Request, device userapi.Device, syncDB storage.Dat
|
|||
if filterQuery[0] == '{' {
|
||||
// attempt to parse the timeline limit at least
|
||||
var f filter
|
||||
err := json.Unmarshal([]byte(filterQuery), &f)
|
||||
err := json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(filterQuery), &f)
|
||||
if err == nil && f.Room.Timeline.Limit != nil {
|
||||
timelineLimit = *f.Room.Timeline.Limit
|
||||
}
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@ func NewInviteResponse(event gomatrixserverlib.HeaderedEvent) *InviteResponse {
|
|||
// If there is then unmarshal it into the response. This will contain the
|
||||
// partial room state such as join rules, room name etc.
|
||||
if inviteRoomState := gjson.GetBytes(event.Unsigned(), "invite_room_state"); inviteRoomState.Exists() {
|
||||
_ = json.Unmarshal([]byte(inviteRoomState.Raw), &res.InviteState.Events)
|
||||
_ = json.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(inviteRoomState.Raw), &res.InviteState.Events)
|
||||
}
|
||||
|
||||
// Then we'll see if we can create a partial of the invite event itself.
|
||||
|
|
@ -488,7 +488,7 @@ func NewInviteResponse(event gomatrixserverlib.HeaderedEvent) *InviteResponse {
|
|||
format, _ := event.RoomVersion.EventFormat()
|
||||
inviteEvent := gomatrixserverlib.ToClientEvent(event.Unwrap(), format)
|
||||
inviteEvent.Unsigned = nil
|
||||
if ev, err := json.Marshal(inviteEvent); err == nil {
|
||||
if ev, err := json.ConfigCompatibleWithStandardLibrary.Marshal(inviteEvent); err == nil {
|
||||
res.InviteState.Events = append(res.InviteState.Events, ev)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ func TestNewInviteResponse(t *testing.T) {
|
|||
}
|
||||
|
||||
res := NewInviteResponse(ev.Headered(gomatrixserverlib.RoomVersionV5))
|
||||
j, err := json.Marshal(res)
|
||||
j, err := json.ConfigCompatibleWithStandardLibrary.Marshal(res)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue