mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 23:03:10 -06:00
use jsoniter instead of encoding/json
This commit is contained in:
parent
1cd525ef0d
commit
1ac0707032
|
|
@ -16,7 +16,7 @@ package consumers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/matrix-org/dendrite/appservice/storage"
|
||||
"github.com/matrix-org/dendrite/appservice/types"
|
||||
|
|
@ -75,7 +75,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 := jsoniter.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
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package inthttp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
|
@ -17,7 +17,7 @@ func AddRoutes(a api.AppServiceQueryAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("appserviceRoomAliasExists", func(req *http.Request) util.JSONResponse {
|
||||
var request api.RoomAliasExistsRequest
|
||||
var response api.RoomAliasExistsResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := a.RoomAliasExists(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -31,7 +31,7 @@ func AddRoutes(a api.AppServiceQueryAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("appserviceUserIDExists", func(req *http.Request) util.JSONResponse {
|
||||
var request api.UserIDExistsRequest
|
||||
var response api.UserIDExistsResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := a.UserIDExists(req.Context(), &request, &response); err != nil {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package postgres
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
|
@ -161,7 +161,7 @@ func retrieveEvents(eventRows *sql.Rows, limit int) (events []gomatrixserverlib.
|
|||
}
|
||||
|
||||
// Unmarshal eventJSON
|
||||
if err = json.Unmarshal(eventJSON, &event); err != nil {
|
||||
if err = jsoniter.Unmarshal(eventJSON, &event); err != nil {
|
||||
return nil, 0, 0, false, err
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ func (s *eventsStatements) insertEvent(
|
|||
event *gomatrixserverlib.HeaderedEvent,
|
||||
) (err error) {
|
||||
// Convert event to JSON before inserting
|
||||
eventJSON, err := json.Marshal(event)
|
||||
eventJSON, err := jsoniter.Marshal(event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package sqlite3
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
|
|
@ -166,7 +166,7 @@ func retrieveEvents(eventRows *sql.Rows, limit int) (events []gomatrixserverlib.
|
|||
}
|
||||
|
||||
// Unmarshal eventJSON
|
||||
if err = json.Unmarshal(eventJSON, &event); err != nil {
|
||||
if err = jsoniter.Unmarshal(eventJSON, &event); err != nil {
|
||||
return nil, 0, 0, false, err
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ func (s *eventsStatements) insertEvent(
|
|||
event *gomatrixserverlib.HeaderedEvent,
|
||||
) (err error) {
|
||||
// Convert event to JSON before inserting
|
||||
eventJSON, err := json.Marshal(event)
|
||||
eventJSON, err := jsoniter.Marshal(event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package workers
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"math"
|
||||
"net/http"
|
||||
|
|
@ -195,7 +195,7 @@ func createTransaction(
|
|||
Events: ev,
|
||||
}
|
||||
|
||||
transactionJSON, err = json.Marshal(transaction)
|
||||
transactionJSON, err = jsoniter.Marshal(transaction)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package auth
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
|
|
@ -181,19 +181,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 := jsoniter.Marshal(response)
|
||||
if err != nil {
|
||||
ise := jsonerror.InternalServerError()
|
||||
return &ise
|
||||
}
|
||||
_ = json.Unmarshal(b, &mixedObjects)
|
||||
_ = jsoniter.Unmarshal(b, &mixedObjects)
|
||||
challenge := u.Challenge(sessionID)
|
||||
b, err = json.Marshal(challenge.JSON)
|
||||
b, err = jsoniter.Marshal(challenge.JSON)
|
||||
if err != nil {
|
||||
ise := jsonerror.InternalServerError()
|
||||
return &ise
|
||||
}
|
||||
_ = json.Unmarshal(b, &mixedObjects)
|
||||
_ = jsoniter.Unmarshal(b, &mixedObjects)
|
||||
|
||||
return &util.JSONResponse{
|
||||
Code: 401,
|
||||
|
|
@ -237,7 +237,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 := jsoniter.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()),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package auth
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ func TestUserInteractivePasswordLogin(t *testing.T) {
|
|||
UserID: fmt.Sprintf("@alice:%s", serverName),
|
||||
}
|
||||
// valid password requests
|
||||
testCases := []json.RawMessage{
|
||||
testCases := []jsoniter.RawMessage{
|
||||
// deprecated form
|
||||
[]byte(`{
|
||||
"auth": {
|
||||
|
|
@ -101,7 +101,7 @@ func TestUserInteractivePasswordBadLogin(t *testing.T) {
|
|||
}
|
||||
// invalid password requests
|
||||
testCases := []struct {
|
||||
body json.RawMessage
|
||||
body jsoniter.RawMessage
|
||||
wantRes util.JSONResponse
|
||||
}{
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
package httputil
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"unicode/utf8"
|
||||
|
|
@ -43,7 +43,7 @@ func UnmarshalJSONRequest(req *http.Request, iface interface{}) *util.JSONRespon
|
|||
}
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(body, iface); err != nil {
|
||||
if err := jsoniter.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.
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@
|
|||
package jsonerror
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLimitExceeded(t *testing.T) {
|
||||
e := LimitExceeded("too fast", 5000)
|
||||
jsonBytes, err := json.Marshal(&e)
|
||||
jsonBytes, err := jsoniter.Marshal(&e)
|
||||
if err != nil {
|
||||
t.Fatalf("TestLimitExceeded: Failed to marshal LimitExceeded error. %s", err.Error())
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ func TestLimitExceeded(t *testing.T) {
|
|||
|
||||
func TestForbidden(t *testing.T) {
|
||||
e := Forbidden("you shall not pass")
|
||||
jsonBytes, err := json.Marshal(&e)
|
||||
jsonBytes, err := jsoniter.Marshal(&e)
|
||||
if err != nil {
|
||||
t.Fatalf("TestForbidden: Failed to marshal Forbidden error. %s", err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
package producers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/matrix-org/dendrite/internal/eventutil"
|
||||
|
|
@ -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 := jsoniter.Marshal(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/json-iterator/go"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ func GetAccountData(
|
|||
return util.ErrorResponse(fmt.Errorf("userAPI.QueryAccountData: %w", err))
|
||||
}
|
||||
|
||||
var data json.RawMessage
|
||||
var data jsoniter.RawMessage
|
||||
var ok bool
|
||||
if roomID != "" {
|
||||
data, ok = dataRes.RoomAccountData[roomID][dataType]
|
||||
|
|
@ -106,7 +106,7 @@ func SaveAccountData(
|
|||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
||||
if !json.Valid(body) {
|
||||
if !jsoniter.Valid(body) {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.BadJSON("Bad JSON content"),
|
||||
|
|
@ -117,7 +117,7 @@ func SaveAccountData(
|
|||
UserID: userID,
|
||||
DataType: dataType,
|
||||
RoomID: roomID,
|
||||
AccountData: json.RawMessage(body),
|
||||
AccountData: jsoniter.RawMessage(body),
|
||||
}
|
||||
dataRes := api.InputAccountDataResponse{}
|
||||
if err := userAPI.InputAccountData(req.Context(), &dataReq, &dataRes); err != nil {
|
||||
|
|
@ -170,7 +170,7 @@ func SaveReadMarker(
|
|||
}
|
||||
}
|
||||
|
||||
data, err := json.Marshal(fullyReadEvent{EventID: r.FullyRead})
|
||||
data, err := jsoniter.Marshal(fullyReadEvent{EventID: r.FullyRead})
|
||||
if err != nil {
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
|
@ -99,7 +99,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 := jsoniter.Marshal(r.CreationContent)
|
||||
if err != nil {
|
||||
return &util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
|
|
@ -108,7 +108,7 @@ func (r createRoomRequest) Validate() *util.JSONResponse {
|
|||
}
|
||||
|
||||
var CreationContent gomatrixserverlib.CreateContent
|
||||
err = json.Unmarshal(creationContentBytes, &CreationContent)
|
||||
err = jsoniter.Unmarshal(creationContentBytes, &CreationContent)
|
||||
if err != nil {
|
||||
return &util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
|
|
@ -27,8 +27,8 @@ import (
|
|||
)
|
||||
|
||||
type uploadKeysRequest struct {
|
||||
DeviceKeys json.RawMessage `json:"device_keys"`
|
||||
OneTimeKeys map[string]json.RawMessage `json:"one_time_keys"`
|
||||
DeviceKeys jsoniter.RawMessage `json:"device_keys"`
|
||||
OneTimeKeys map[string]jsoniter.RawMessage `json:"one_time_keys"`
|
||||
}
|
||||
|
||||
func UploadKeys(req *http.Request, keyAPI api.KeyInternalAPI, device *userapi.Device) util.JSONResponse {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
|
|
@ -73,7 +73,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 := jsoniter.Unmarshal(ev.Content, &content); err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Error("failed to unmarshal event content")
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import (
|
|||
"context"
|
||||
"crypto/hmac"
|
||||
"crypto/sha1"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
|
@ -301,7 +301,7 @@ func validateRecaptcha(
|
|||
JSON: jsonerror.Unknown("Error in contacting captcha server" + err.Error()),
|
||||
}
|
||||
}
|
||||
err = json.Unmarshal(body, &r)
|
||||
err = jsoniter.Unmarshal(body, &r)
|
||||
if err != nil {
|
||||
return &util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
|
@ -183,7 +183,7 @@ func obtainSavedTags(
|
|||
if !ok {
|
||||
return
|
||||
}
|
||||
if err = json.Unmarshal(data, &tags); err != nil {
|
||||
if err = jsoniter.Unmarshal(data, &tags); err != nil {
|
||||
return
|
||||
}
|
||||
return tags, nil
|
||||
|
|
@ -197,7 +197,7 @@ func saveTagData(
|
|||
userAPI api.UserInternalAPI,
|
||||
Tag gomatrix.TagContent,
|
||||
) error {
|
||||
newTagData, err := json.Marshal(Tag)
|
||||
newTagData, err := jsoniter.Marshal(Tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ func saveTagData(
|
|||
UserID: userID,
|
||||
RoomID: roomID,
|
||||
DataType: "m.tag",
|
||||
AccountData: json.RawMessage(newTagData),
|
||||
AccountData: jsoniter.RawMessage(newTagData),
|
||||
}
|
||||
dataRes := api.InputAccountDataResponse{}
|
||||
return userAPI.InputAccountData(req.Context(), &dataReq, &dataRes)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
|
|
@ -466,7 +466,7 @@ func Setup(
|
|||
r0mux.Handle("/pushrules/",
|
||||
httputil.MakeExternalAPI("push_rules", func(req *http.Request) util.JSONResponse {
|
||||
// TODO: Implement push rules API
|
||||
res := json.RawMessage(`{
|
||||
res := jsoniter.RawMessage(`{
|
||||
"global": {
|
||||
"content": [],
|
||||
"override": [],
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/httputil"
|
||||
|
|
@ -39,7 +39,7 @@ func SendToDevice(
|
|||
}
|
||||
|
||||
var httpReq struct {
|
||||
Messages map[string]map[string]json.RawMessage `json:"messages"`
|
||||
Messages map[string]map[string]jsoniter.RawMessage `json:"messages"`
|
||||
}
|
||||
resErr := httputil.UnmarshalJSONRequest(req, &httpReq)
|
||||
if resErr != nil {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package routing
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ import (
|
|||
|
||||
type stateEventInStateResp struct {
|
||||
gomatrixserverlib.ClientEvent
|
||||
PrevContent json.RawMessage `json:"prev_content,omitempty"`
|
||||
PrevContent jsoniter.RawMessage `json:"prev_content,omitempty"`
|
||||
ReplacesState string `json:"replaces_state,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +63,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 := jsoniter.Unmarshal(ev.Content(), &content); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("json.Unmarshal for history visibility failed")
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
|
@ -204,7 +204,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 := jsoniter.Unmarshal(ev.Content(), &content); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("json.Unmarshal for history visibility failed")
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package threepid
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
|
@ -197,7 +197,7 @@ func queryIDServerLookup(ctx context.Context, body *MembershipRequest) (*idServe
|
|||
}
|
||||
|
||||
var res idServerLookupResponse
|
||||
err = json.NewDecoder(resp.Body).Decode(&res)
|
||||
err = jsoniter.NewDecoder(resp.Body).Decode(&res)
|
||||
return &res, err
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ func queryIDServerStoreInvite(
|
|||
}
|
||||
|
||||
var idResp idServerStoreInviteResponse
|
||||
err = json.NewDecoder(resp.Body).Decode(&idResp)
|
||||
err = jsoniter.NewDecoder(resp.Body).Decode(&idResp)
|
||||
return &idResp, err
|
||||
}
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ func queryIDServerPubKey(ctx context.Context, idServerName string, keyID string)
|
|||
return nil, errors.New(errMsg)
|
||||
}
|
||||
|
||||
err = json.NewDecoder(resp.Body).Decode(&pubKeyRes)
|
||||
err = jsoniter.NewDecoder(resp.Body).Decode(&pubKeyRes)
|
||||
return pubKeyRes.PublicKey, err
|
||||
}
|
||||
|
||||
|
|
@ -302,7 +302,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 := jsoniter.Marshal(*res)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package threepid
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
|
@ -88,7 +88,7 @@ func CreateSession(
|
|||
var sid struct {
|
||||
SID string `json:"sid"`
|
||||
}
|
||||
err = json.NewDecoder(resp.Body).Decode(&sid)
|
||||
err = jsoniter.NewDecoder(resp.Body).Decode(&sid)
|
||||
|
||||
return sid.SID, err
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ func CheckAssociation(
|
|||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(resp.Body).Decode(&respBody); err != nil {
|
||||
if err = jsoniter.NewDecoder(resp.Body).Decode(&respBody); err != nil {
|
||||
return false, "", "", err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
|
@ -124,7 +124,7 @@ func buildAndOutput() gomatrixserverlib.EventReference {
|
|||
|
||||
// Write an event to the output.
|
||||
func writeEvent(event gomatrixserverlib.Event) {
|
||||
encoder := json.NewEncoder(os.Stdout)
|
||||
encoder := jsoniter.NewEncoder(os.Stdout)
|
||||
if *format == "InputRoomEvent" {
|
||||
var ire api.InputRoomEvent
|
||||
ire.Kind = api.KindNew
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
|
@ -110,7 +110,7 @@ func (p *publicRoomsProvider) AdvertiseRooms() error {
|
|||
}
|
||||
advertised := 0
|
||||
for _, room := range ourRooms {
|
||||
if j, err := json.Marshal(room); err == nil {
|
||||
if j, err := jsoniter.Marshal(room); err == nil {
|
||||
if err := p.topic.Publish(context.TODO(), j); err != nil {
|
||||
fmt.Println("Failed to publish public room:", err)
|
||||
} else {
|
||||
|
|
@ -132,7 +132,7 @@ func (p *publicRoomsProvider) FindRooms() {
|
|||
received := discoveredRoom{
|
||||
time: time.Now(),
|
||||
}
|
||||
if err := json.Unmarshal(msg.Data, &received.room); err != nil {
|
||||
if err := jsoniter.Unmarshal(msg.Data, &received.room); err != nil {
|
||||
fmt.Println("Unmarshal error:", err)
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import (
|
|||
"crypto/ed25519"
|
||||
"crypto/tls"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
|
@ -89,7 +89,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 := jsoniter.Unmarshal([]byte(yggconf), &n.config); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ func Setup(instanceName, storageDirectory string) (*Node, error) {
|
|||
n.config.EncryptionPrivateKey = hex.EncodeToString(n.EncryptionPrivateKey())
|
||||
n.config.EncryptionPublicKey = hex.EncodeToString(n.EncryptionPublicKey())
|
||||
|
||||
j, err := json.MarshalIndent(n.config, "", " ")
|
||||
j, err := jsoniter.MarshalIndent(n.config, "", " ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"crypto/ed25519"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"encoding/pem"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
|
@ -75,7 +75,7 @@ func main() {
|
|||
bodyBytes = append(bodyBytes, bytes...)
|
||||
}
|
||||
fmt.Println("Done!")
|
||||
if err = json.Unmarshal(bodyBytes, &bodyObj); err != nil {
|
||||
if err = jsoniter.Unmarshal(bodyBytes, &bodyObj); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
j, err := json.MarshalIndent(res, "", " ")
|
||||
j, err := jsoniter.MarshalIndent(res, "", " ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"net/http"
|
||||
|
||||
|
|
@ -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 = jsoniter.Unmarshal([]byte(input[i]), &request.InputRoomEvents[i]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
|
@ -100,13 +100,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 := jsoniter.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 := jsoniter.Marshal(clientEvs[0])
|
||||
if err != nil {
|
||||
panic("failed to marshal client event as json: " + err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package api
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
|
@ -48,7 +48,7 @@ func SendToDevice(
|
|||
ctx context.Context, eduAPI EDUServerInputAPI, sender, userID, deviceID, eventType string,
|
||||
message interface{},
|
||||
) error {
|
||||
js, err := json.Marshal(message)
|
||||
js, err := jsoniter.Marshal(message)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package input
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"time"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
|
|
@ -93,7 +93,7 @@ func (t *EDUServerInputAPI) sendTypingEvent(ite *api.InputTypingEvent) error {
|
|||
ote.ExpireTime = &expireTime
|
||||
}
|
||||
|
||||
eventJSON, err := json.Marshal(ote)
|
||||
eventJSON, err := jsoniter.Marshal(ote)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -152,9 +152,9 @@ func (t *EDUServerInputAPI) sendToDeviceEvent(ise *api.InputSendToDeviceEvent) e
|
|||
SendToDeviceEvent: ise.SendToDeviceEvent,
|
||||
}
|
||||
|
||||
eventJSON, err := json.Marshal(ote)
|
||||
eventJSON, err := jsoniter.Marshal(ote)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("sendToDevice failed json.Marshal")
|
||||
logrus.WithError(err).Error("sendToDevice failed jsoniter.Marshal")
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package inthttp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
|
@ -16,7 +16,7 @@ func AddRoutes(t api.EDUServerInputAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("inputTypingEvents", func(req *http.Request) util.JSONResponse {
|
||||
var request api.InputTypingEventRequest
|
||||
var response api.InputTypingEventResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := t.InputTypingEvent(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -29,7 +29,7 @@ func AddRoutes(t api.EDUServerInputAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("inputSendToDeviceEvents", func(req *http.Request) util.JSONResponse {
|
||||
var request api.InputSendToDeviceEventRequest
|
||||
var response api.InputSendToDeviceEventResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := t.InputSendToDeviceEvent(req.Context(), &request, &response); err != nil {
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ func Backfill(
|
|||
}
|
||||
}
|
||||
|
||||
eventJSONs := []json.RawMessage{}
|
||||
var eventJSONs []json.RawMessage
|
||||
for _, e := range gomatrixserverlib.ReverseTopologicalOrdering(
|
||||
evs,
|
||||
gomatrixserverlib.TopologicalOrderByPrevEvents,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
|
|
@ -45,7 +45,7 @@ func GetUserDevices(
|
|||
|
||||
for _, dev := range res.Devices {
|
||||
var key gomatrixserverlib.RespUserDeviceKeys
|
||||
err := json.Unmarshal(dev.DeviceKeys.KeyJSON, &key)
|
||||
err := jsoniter.Unmarshal(dev.DeviceKeys.KeyJSON, &key)
|
||||
if err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Warnf("malformed device key: %s", string(dev.DeviceKeys.KeyJSON))
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package routing
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ func InviteV2(
|
|||
keys gomatrixserverlib.JSONVerifier,
|
||||
) util.JSONResponse {
|
||||
inviteReq := gomatrixserverlib.InviteV2Request{}
|
||||
err := json.Unmarshal(request.Content(), &inviteReq)
|
||||
err := jsoniter.Unmarshal(request.Content(), &inviteReq)
|
||||
switch err.(type) {
|
||||
case gomatrixserverlib.BadJSONError:
|
||||
return util.JSONResponse{
|
||||
|
|
@ -85,7 +85,7 @@ func InviteV1(
|
|||
}
|
||||
}
|
||||
var strippedState []gomatrixserverlib.InviteV2StrippedState
|
||||
if err := json.Unmarshal(event.Unsigned(), &strippedState); err != nil {
|
||||
if err := jsoniter.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")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
|
|
@ -40,7 +40,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 := jsoniter.Unmarshal(request.Content(), &qkr)
|
||||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
|
|
@ -86,7 +86,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 := jsoniter.Unmarshal(request.Content(), &cor)
|
||||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
|
|
@ -156,7 +156,7 @@ func localKeys(cfg *config.FederationAPI, validUntil time.Time) (*gomatrixserver
|
|||
}
|
||||
}
|
||||
|
||||
toSign, err := json.Marshal(keys.ServerKeyFields)
|
||||
toSign, err := jsoniter.Marshal(keys.ServerKeyFields)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -184,9 +184,9 @@ func NotaryKeys(
|
|||
}
|
||||
|
||||
var response struct {
|
||||
ServerKeys []json.RawMessage `json:"server_keys"`
|
||||
ServerKeys []jsoniter.RawMessage `json:"server_keys"`
|
||||
}
|
||||
response.ServerKeys = []json.RawMessage{}
|
||||
response.ServerKeys = []jsoniter.RawMessage{}
|
||||
|
||||
for serverName := range req.ServerKeys {
|
||||
var keys *gomatrixserverlib.ServerKeys
|
||||
|
|
@ -207,7 +207,7 @@ func NotaryKeys(
|
|||
continue
|
||||
}
|
||||
|
||||
j, err := json.Marshal(keys)
|
||||
j, err := jsoniter.Marshal(keys)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to marshal %q response", serverName)
|
||||
return jsonerror.InternalServerError()
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
|
|
@ -38,7 +38,7 @@ func GetMissingEvents(
|
|||
roomID string,
|
||||
) util.JSONResponse {
|
||||
var gme getMissingEventRequest
|
||||
if err := json.Unmarshal(request.Content(), &gme); err != nil {
|
||||
if err := jsoniter.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()),
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package routing
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
|
@ -59,7 +60,7 @@ func Send(
|
|||
EDUs []gomatrixserverlib.EDU `json:"edus"`
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(request.Content(), &txnEvents); err != nil {
|
||||
if err := jsoniter.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()),
|
||||
|
|
@ -132,7 +133,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 := jsoniter.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
|
||||
|
|
@ -295,7 +296,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 := jsoniter.Unmarshal(e.Content, &typingPayload); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("Failed to unmarshal typing event")
|
||||
continue
|
||||
}
|
||||
|
|
@ -305,7 +306,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 := jsoniter.Unmarshal(e.Content, &directPayload); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("Failed to unmarshal send-to-device events")
|
||||
continue
|
||||
}
|
||||
|
|
@ -331,7 +332,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 := jsoniter.Unmarshal(e.Content, &payload); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("Failed to unmarshal device list update event")
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package routing
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package routing
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
|
@ -110,7 +110,7 @@ func ExchangeThirdPartyInvite(
|
|||
federation *gomatrixserverlib.FederationClient,
|
||||
) util.JSONResponse {
|
||||
var builder gomatrixserverlib.EventBuilder
|
||||
if err := json.Unmarshal(request.Content(), &builder); err != nil {
|
||||
if err := jsoniter.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()),
|
||||
|
|
@ -367,7 +367,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 := jsoniter.Unmarshal(builder.Content, &content); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -380,7 +380,7 @@ func fillDisplayName(
|
|||
}
|
||||
|
||||
var thirdPartyInviteContent gomatrixserverlib.ThirdPartyInviteContent
|
||||
if err := json.Unmarshal(thirdPartyInviteEvent.Content(), &thirdPartyInviteContent); err != nil {
|
||||
if err := jsoniter.Unmarshal(thirdPartyInviteEvent.Content(), &thirdPartyInviteContent); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package consumers
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
|
|
@ -89,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 := jsoniter.Unmarshal(msg.Value, &ote); err != nil {
|
||||
log.WithError(err).Errorf("eduserver output log: message parse failed (expected send-to-device)")
|
||||
return nil
|
||||
}
|
||||
|
|
@ -126,7 +127,7 @@ func (t *OutputEDUConsumer) onSendToDeviceEvent(msg *sarama.ConsumerMessage) err
|
|||
},
|
||||
},
|
||||
}
|
||||
if edu.Content, err = json.Marshal(tdm); err != nil {
|
||||
if edu.Content, err = jsoniter.Marshal(tdm); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -139,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 := jsoniter.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
|
||||
|
|
@ -167,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 = jsoniter.Marshal(map[string]interface{}{
|
||||
"room_id": ote.Event.RoomID,
|
||||
"user_id": ote.Event.UserID,
|
||||
"typing": ote.Event.Typing,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package consumers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
|
|
@ -76,7 +76,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 := jsoniter.Unmarshal(msg.Value, &m); err != nil {
|
||||
log.WithError(err).Errorf("failed to read device message from key change topic")
|
||||
return nil
|
||||
}
|
||||
|
|
@ -122,7 +122,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 = jsoniter.Marshal(event); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package consumers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
|
|
@ -77,7 +77,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 := jsoniter.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
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package inthttp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
|
@ -18,7 +18,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
httputil.MakeInternalAPI("QueryJoinedHostServerNamesInRoom", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryJoinedHostServerNamesInRoomRequest
|
||||
var response api.QueryJoinedHostServerNamesInRoomResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := intAPI.QueryJoinedHostServerNamesInRoom(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -32,7 +32,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
httputil.MakeInternalAPI("PerformJoinRequest", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformJoinRequest
|
||||
var response api.PerformJoinResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
intAPI.PerformJoin(req.Context(), &request, &response)
|
||||
|
|
@ -44,7 +44,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
httputil.MakeInternalAPI("PerformLeaveRequest", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformLeaveRequest
|
||||
var response api.PerformLeaveResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := intAPI.PerformLeave(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -58,7 +58,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
httputil.MakeInternalAPI("PerformInviteRequest", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformInviteRequest
|
||||
var response api.PerformInviteResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := intAPI.PerformInvite(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -72,7 +72,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
httputil.MakeInternalAPI("PerformDirectoryLookupRequest", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformDirectoryLookupRequest
|
||||
var response api.PerformDirectoryLookupResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := intAPI.PerformDirectoryLookup(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -86,7 +86,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
httputil.MakeInternalAPI("PerformServersAliveRequest", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformServersAliveRequest
|
||||
var response api.PerformServersAliveResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := intAPI.PerformServersAlive(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -100,7 +100,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
httputil.MakeInternalAPI("PerformBroadcastEDU", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformBroadcastEDURequest
|
||||
var response api.PerformBroadcastEDUResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := intAPI.PerformBroadcastEDU(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -113,7 +113,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
FederationSenderGetUserDevicesPath,
|
||||
httputil.MakeInternalAPI("GetUserDevices", func(req *http.Request) util.JSONResponse {
|
||||
var request getUserDevices
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
res, err := intAPI.GetUserDevices(req.Context(), request.S, request.UserID)
|
||||
|
|
@ -135,7 +135,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
FederationSenderClaimKeysPath,
|
||||
httputil.MakeInternalAPI("ClaimKeys", func(req *http.Request) util.JSONResponse {
|
||||
var request claimKeys
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
res, err := intAPI.ClaimKeys(req.Context(), request.S, request.OneTimeKeys)
|
||||
|
|
@ -157,7 +157,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
FederationSenderQueryKeysPath,
|
||||
httputil.MakeInternalAPI("QueryKeys", func(req *http.Request) util.JSONResponse {
|
||||
var request queryKeys
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
res, err := intAPI.QueryKeys(req.Context(), request.S, request.Keys)
|
||||
|
|
@ -179,7 +179,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
FederationSenderBackfillPath,
|
||||
httputil.MakeInternalAPI("Backfill", func(req *http.Request) util.JSONResponse {
|
||||
var request backfill
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
res, err := intAPI.Backfill(req.Context(), request.S, request.RoomID, request.Limit, request.EventIDs)
|
||||
|
|
@ -201,7 +201,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
FederationSenderLookupStatePath,
|
||||
httputil.MakeInternalAPI("LookupState", func(req *http.Request) util.JSONResponse {
|
||||
var request lookupState
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
res, err := intAPI.LookupState(req.Context(), request.S, request.RoomID, request.EventID, request.RoomVersion)
|
||||
|
|
@ -223,7 +223,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
FederationSenderLookupStateIDsPath,
|
||||
httputil.MakeInternalAPI("LookupStateIDs", func(req *http.Request) util.JSONResponse {
|
||||
var request lookupStateIDs
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
res, err := intAPI.LookupStateIDs(req.Context(), request.S, request.RoomID, request.EventID)
|
||||
|
|
@ -245,7 +245,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
FederationSenderGetEventPath,
|
||||
httputil.MakeInternalAPI("GetEvent", func(req *http.Request) util.JSONResponse {
|
||||
var request getEvent
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
res, err := intAPI.GetEvent(req.Context(), request.S, request.EventID)
|
||||
|
|
@ -267,7 +267,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
FederationSenderGetServerKeysPath,
|
||||
httputil.MakeInternalAPI("GetServerKeys", func(req *http.Request) util.JSONResponse {
|
||||
var request getServerKeys
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
res, err := intAPI.GetServerKeys(req.Context(), request.S)
|
||||
|
|
@ -289,7 +289,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
|
|||
FederationSenderLookupServerKeysPath,
|
||||
httputil.MakeInternalAPI("LookupServerKeys", func(req *http.Request) util.JSONResponse {
|
||||
var request lookupServerKeys
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
res, err := intAPI.LookupServerKeys(req.Context(), request.S, request.KeyRequests)
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ func (oq *destinationQueue) nextTransaction() (bool, error) {
|
|||
// Go through PDUs that we retrieved from the database, if any,
|
||||
// and add them into the transaction.
|
||||
for _, pdu := range pdus {
|
||||
// Append the JSON of the event, since this is a json.RawMessage type in the
|
||||
// Append the JSON of the event, since this is a jsoniter.RawMessage type in the
|
||||
// gomatrixserverlib.Transaction struct
|
||||
t.PDUs = append(t.PDUs, (*pdu).JSON())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package queue
|
|||
import (
|
||||
"context"
|
||||
"crypto/ed25519"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
|
@ -159,9 +159,9 @@ func (oqs *OutgoingQueues) SendEvent(
|
|||
"destinations": len(destmap), "event": ev.EventID(),
|
||||
}).Infof("Sending event")
|
||||
|
||||
headeredJSON, err := json.Marshal(ev)
|
||||
headeredJSON, err := jsoniter.Marshal(ev)
|
||||
if err != nil {
|
||||
return fmt.Errorf("json.Marshal: %w", err)
|
||||
return fmt.Errorf("jsoniter.Marshal: %w", err)
|
||||
}
|
||||
|
||||
nid, err := oqs.db.StoreJSON(context.TODO(), string(headeredJSON))
|
||||
|
|
@ -224,9 +224,9 @@ func (oqs *OutgoingQueues) SendEDU(
|
|||
"destinations": len(destmap), "edu_type": e.Type,
|
||||
}).Info("Sending EDU event")
|
||||
|
||||
ephemeralJSON, err := json.Marshal(e)
|
||||
ephemeralJSON, err := jsoniter.Marshal(e)
|
||||
if err != nil {
|
||||
return fmt.Errorf("json.Marshal: %w", err)
|
||||
return fmt.Errorf("jsoniter.Marshal: %w", err)
|
||||
}
|
||||
|
||||
nid, err := oqs.db.StoreJSON(context.TODO(), string(ephemeralJSON))
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package shared
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
|
||||
"github.com/matrix-org/dendrite/federationsender/storage/tables"
|
||||
|
|
@ -50,7 +50,7 @@ func (e *Receipt) Empty() bool {
|
|||
}
|
||||
|
||||
func (e *Receipt) String() string {
|
||||
j, _ := json.Marshal(e.nids)
|
||||
j, _ := jsoniter.Marshal(e.nids)
|
||||
return string(j)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package shared
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ func (d *Database) GetNextTransactionEDUs(
|
|||
|
||||
for _, blob := range blobs {
|
||||
var event gomatrixserverlib.EDU
|
||||
if err := json.Unmarshal(blob, &event); err != nil {
|
||||
if err := jsoniter.Unmarshal(blob, &event); err != nil {
|
||||
return fmt.Errorf("json.Unmarshal: %w", err)
|
||||
}
|
||||
edus = append(edus, &event)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package shared
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ func (d *Database) GetNextTransactionPDUs(
|
|||
|
||||
for _, blob := range blobs {
|
||||
var event gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(blob, &event); err != nil {
|
||||
if err := jsoniter.Unmarshal(blob, &event); err != nil {
|
||||
return fmt.Errorf("json.Unmarshal: %w", err)
|
||||
}
|
||||
events = append(events, &event)
|
||||
|
|
|
|||
1
go.mod
1
go.mod
|
|
@ -7,6 +7,7 @@ require (
|
|||
github.com/gologme/log v1.2.0
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/hashicorp/golang-lru v0.5.4
|
||||
github.com/json-iterator/go v1.1.10
|
||||
github.com/lib/pq v1.8.0
|
||||
github.com/libp2p/go-libp2p v0.11.0
|
||||
github.com/libp2p/go-libp2p-circuit v0.3.1
|
||||
|
|
|
|||
3
go.sum
3
go.sum
|
|
@ -282,6 +282,7 @@ github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M
|
|||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
|
|
@ -609,8 +610,10 @@ github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl
|
|||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
|
||||
github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package httputil
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
|
@ -32,7 +32,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 := jsoniter.Marshal(request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -72,10 +72,10 @@ func PostJSON(
|
|||
var errorBody struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
if msgerr := json.NewDecoder(res.Body).Decode(&errorBody); msgerr == nil {
|
||||
if msgerr := jsoniter.NewDecoder(res.Body).Decode(&errorBody); msgerr == nil {
|
||||
return fmt.Errorf("Internal API: %d from %s: %s", res.StatusCode, apiURL, errorBody.Message)
|
||||
}
|
||||
return fmt.Errorf("Internal API: %d from %s", res.StatusCode, apiURL)
|
||||
}
|
||||
return json.NewDecoder(res.Body).Decode(response)
|
||||
return jsoniter.NewDecoder(res.Body).Decode(response)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package api
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ type OneTimeKeys struct {
|
|||
// The device ID of this device
|
||||
DeviceID string
|
||||
// A map of algorithm:key_id => key JSON
|
||||
KeyJSON map[string]json.RawMessage
|
||||
KeyJSON map[string]jsoniter.RawMessage
|
||||
}
|
||||
|
||||
// Split a key in KeyJSON into algorithm and key ID
|
||||
|
|
@ -142,7 +142,7 @@ type PerformClaimKeysRequest struct {
|
|||
|
||||
type PerformClaimKeysResponse struct {
|
||||
// Map of user_id to device_id to algorithm:key_id to key JSON
|
||||
OneTimeKeys map[string]map[string]map[string]json.RawMessage
|
||||
OneTimeKeys map[string]map[string]map[string]jsoniter.RawMessage
|
||||
// Map of remote server domain to error JSON
|
||||
Failures map[string]interface{}
|
||||
// Set if there was a fatal error processing this action
|
||||
|
|
@ -159,7 +159,7 @@ type QueryKeysResponse struct {
|
|||
// Map of remote server domain to error JSON
|
||||
Failures map[string]interface{}
|
||||
// Map of user_id to device_id to device_key
|
||||
DeviceKeys map[string]map[string]json.RawMessage
|
||||
DeviceKeys map[string]map[string]jsoniter.RawMessage
|
||||
// Set if there was a fatal error processing this query
|
||||
Error *KeyError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package internal
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"hash/fnv"
|
||||
"sync"
|
||||
|
|
@ -369,7 +369,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 := jsoniter.Marshal(device.Keys)
|
||||
if err != nil {
|
||||
util.GetLogger(ctx).WithField("keys", device.Keys).Error("failed to marshal keys, skipping device")
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package internal
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
|
@ -80,7 +80,7 @@ func (a *KeyInternalAPI) PerformUploadKeys(ctx context.Context, req *api.Perform
|
|||
}
|
||||
|
||||
func (a *KeyInternalAPI) PerformClaimKeys(ctx context.Context, req *api.PerformClaimKeysRequest, res *api.PerformClaimKeysResponse) {
|
||||
res.OneTimeKeys = make(map[string]map[string]map[string]json.RawMessage)
|
||||
res.OneTimeKeys = make(map[string]map[string]map[string]jsoniter.RawMessage)
|
||||
res.Failures = make(map[string]interface{})
|
||||
// wrap request map in a top-level by-domain map
|
||||
domainToDeviceKeys := make(map[string]map[string]map[string]string)
|
||||
|
|
@ -108,11 +108,11 @@ func (a *KeyInternalAPI) PerformClaimKeys(ctx context.Context, req *api.PerformC
|
|||
for _, key := range keys {
|
||||
_, ok := res.OneTimeKeys[key.UserID]
|
||||
if !ok {
|
||||
res.OneTimeKeys[key.UserID] = make(map[string]map[string]json.RawMessage)
|
||||
res.OneTimeKeys[key.UserID] = make(map[string]map[string]jsoniter.RawMessage)
|
||||
}
|
||||
_, ok = res.OneTimeKeys[key.UserID][key.DeviceID]
|
||||
if !ok {
|
||||
res.OneTimeKeys[key.UserID][key.DeviceID] = make(map[string]json.RawMessage)
|
||||
res.OneTimeKeys[key.UserID][key.DeviceID] = make(map[string]jsoniter.RawMessage)
|
||||
}
|
||||
for keyID, keyJSON := range key.KeyJSON {
|
||||
res.OneTimeKeys[key.UserID][key.DeviceID][keyID] = keyJSON
|
||||
|
|
@ -165,11 +165,11 @@ func (a *KeyInternalAPI) claimRemoteKeys(
|
|||
keysClaimed := 0
|
||||
for result := range resultCh {
|
||||
for userID, nest := range result.OneTimeKeys {
|
||||
res.OneTimeKeys[userID] = make(map[string]map[string]json.RawMessage)
|
||||
res.OneTimeKeys[userID] = make(map[string]map[string]jsoniter.RawMessage)
|
||||
for deviceID, nest2 := range nest {
|
||||
res.OneTimeKeys[userID][deviceID] = make(map[string]json.RawMessage)
|
||||
res.OneTimeKeys[userID][deviceID] = make(map[string]jsoniter.RawMessage)
|
||||
for keyIDWithAlgo, otk := range nest2 {
|
||||
keyJSON, err := json.Marshal(otk)
|
||||
keyJSON, err := jsoniter.Marshal(otk)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ func (a *KeyInternalAPI) QueryDeviceMessages(ctx context.Context, req *api.Query
|
|||
}
|
||||
|
||||
func (a *KeyInternalAPI) QueryKeys(ctx context.Context, req *api.QueryKeysRequest, res *api.QueryKeysResponse) {
|
||||
res.DeviceKeys = make(map[string]map[string]json.RawMessage)
|
||||
res.DeviceKeys = make(map[string]map[string]jsoniter.RawMessage)
|
||||
res.Failures = make(map[string]interface{})
|
||||
// make a map from domain to device keys
|
||||
domainToDeviceKeys := make(map[string]map[string][]string)
|
||||
|
|
@ -254,7 +254,7 @@ func (a *KeyInternalAPI) QueryKeys(ctx context.Context, req *api.QueryKeysReques
|
|||
}
|
||||
|
||||
if res.DeviceKeys[userID] == nil {
|
||||
res.DeviceKeys[userID] = make(map[string]json.RawMessage)
|
||||
res.DeviceKeys[userID] = make(map[string]jsoniter.RawMessage)
|
||||
}
|
||||
for _, dk := range deviceKeys {
|
||||
if len(dk.KeyJSON) == 0 {
|
||||
|
|
@ -335,9 +335,9 @@ func (a *KeyInternalAPI) queryRemoteKeys(
|
|||
|
||||
for result := range resultCh {
|
||||
for userID, nest := range result.DeviceKeys {
|
||||
res.DeviceKeys[userID] = make(map[string]json.RawMessage)
|
||||
res.DeviceKeys[userID] = make(map[string]jsoniter.RawMessage)
|
||||
for deviceID, deviceKey := range nest {
|
||||
keyJSON, err := json.Marshal(deviceKey)
|
||||
keyJSON, err := jsoniter.Marshal(deviceKey)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
|
@ -432,7 +432,7 @@ func (a *KeyInternalAPI) populateResponseWithDeviceKeysFromDatabase(
|
|||
return fmt.Errorf("DeviceKeysForUser %s returned no keys but wanted all keys, falling back to remote", userID)
|
||||
}
|
||||
if res.DeviceKeys[userID] == nil {
|
||||
res.DeviceKeys[userID] = make(map[string]json.RawMessage)
|
||||
res.DeviceKeys[userID] = make(map[string]jsoniter.RawMessage)
|
||||
}
|
||||
|
||||
for _, key := range keys {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
package inthttp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
|
@ -29,7 +29,7 @@ func AddRoutes(internalAPIMux *mux.Router, s api.KeyInternalAPI) {
|
|||
httputil.MakeInternalAPI("inputDeviceListUpdate", func(req *http.Request) util.JSONResponse {
|
||||
request := api.InputDeviceListUpdateRequest{}
|
||||
response := api.InputDeviceListUpdateResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
s.InputDeviceListUpdate(req.Context(), &request, &response)
|
||||
|
|
@ -40,7 +40,7 @@ func AddRoutes(internalAPIMux *mux.Router, s api.KeyInternalAPI) {
|
|||
httputil.MakeInternalAPI("performClaimKeys", func(req *http.Request) util.JSONResponse {
|
||||
request := api.PerformClaimKeysRequest{}
|
||||
response := api.PerformClaimKeysResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
s.PerformClaimKeys(req.Context(), &request, &response)
|
||||
|
|
@ -51,7 +51,7 @@ func AddRoutes(internalAPIMux *mux.Router, s api.KeyInternalAPI) {
|
|||
httputil.MakeInternalAPI("performUploadKeys", func(req *http.Request) util.JSONResponse {
|
||||
request := api.PerformUploadKeysRequest{}
|
||||
response := api.PerformUploadKeysResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
s.PerformUploadKeys(req.Context(), &request, &response)
|
||||
|
|
@ -62,7 +62,7 @@ func AddRoutes(internalAPIMux *mux.Router, s api.KeyInternalAPI) {
|
|||
httputil.MakeInternalAPI("queryKeys", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QueryKeysRequest{}
|
||||
response := api.QueryKeysResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
s.QueryKeys(req.Context(), &request, &response)
|
||||
|
|
@ -73,7 +73,7 @@ func AddRoutes(internalAPIMux *mux.Router, s api.KeyInternalAPI) {
|
|||
httputil.MakeInternalAPI("queryOneTimeKeys", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QueryOneTimeKeysRequest{}
|
||||
response := api.QueryOneTimeKeysResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
s.QueryOneTimeKeys(req.Context(), &request, &response)
|
||||
|
|
@ -84,7 +84,7 @@ func AddRoutes(internalAPIMux *mux.Router, s api.KeyInternalAPI) {
|
|||
httputil.MakeInternalAPI("queryDeviceMessages", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QueryDeviceMessagesRequest{}
|
||||
response := api.QueryDeviceMessagesResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
s.QueryDeviceMessages(req.Context(), &request, &response)
|
||||
|
|
@ -95,7 +95,7 @@ func AddRoutes(internalAPIMux *mux.Router, s api.KeyInternalAPI) {
|
|||
httputil.MakeInternalAPI("queryKeyChanges", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QueryKeyChangesRequest{}
|
||||
response := api.QueryKeyChangesResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
s.QueryKeyChanges(req.Context(), &request, &response)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package producers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/matrix-org/dendrite/keyserver/api"
|
||||
|
|
@ -46,7 +46,7 @@ func (p *KeyChange) ProduceKeyChanges(keys []api.DeviceMessage) error {
|
|||
for _, key := range keys {
|
||||
var m sarama.ProducerMessage
|
||||
|
||||
value, err := json.Marshal(key)
|
||||
value, err := jsoniter.Marshal(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ package storage
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/matrix-org/dendrite/keyserver/api"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
)
|
||||
|
|
@ -25,7 +24,7 @@ import (
|
|||
type Database interface {
|
||||
// ExistingOneTimeKeys returns a map of keyIDWithAlgorithm to key JSON for the given parameters. If no keys exist with this combination
|
||||
// of user/device/key/algorithm 4-uple then it is omitted from the map. Returns an error when failing to communicate with the database.
|
||||
ExistingOneTimeKeys(ctx context.Context, userID, deviceID string, keyIDsWithAlgorithms []string) (map[string]json.RawMessage, error)
|
||||
ExistingOneTimeKeys(ctx context.Context, userID, deviceID string, keyIDsWithAlgorithms []string) (map[string]jsoniter.RawMessage, error)
|
||||
|
||||
// StoreOneTimeKeys persists the given one-time keys.
|
||||
StoreOneTimeKeys(ctx context.Context, keys api.OneTimeKeys) (*api.OneTimeKeysCount, error)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package postgres
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
|
|
@ -93,7 +93,7 @@ func NewPostgresOneTimeKeysTable(db *sql.DB) (tables.OneTimeKeys, error) {
|
|||
return s, nil
|
||||
}
|
||||
|
||||
func (s *oneTimeKeysStatements) SelectOneTimeKeys(ctx context.Context, userID, deviceID string, keyIDsWithAlgorithms []string) (map[string]json.RawMessage, error) {
|
||||
func (s *oneTimeKeysStatements) SelectOneTimeKeys(ctx context.Context, userID, deviceID string, keyIDsWithAlgorithms []string) (map[string]jsoniter.RawMessage, error) {
|
||||
rows, err := s.selectKeysStmt.QueryContext(ctx, userID, deviceID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -105,7 +105,7 @@ func (s *oneTimeKeysStatements) SelectOneTimeKeys(ctx context.Context, userID, d
|
|||
wantSet[ka] = true
|
||||
}
|
||||
|
||||
result := make(map[string]json.RawMessage)
|
||||
result := make(map[string]jsoniter.RawMessage)
|
||||
for rows.Next() {
|
||||
var keyID string
|
||||
var algorithm string
|
||||
|
|
@ -115,7 +115,7 @@ func (s *oneTimeKeysStatements) SelectOneTimeKeys(ctx context.Context, userID, d
|
|||
}
|
||||
keyIDWithAlgo := algorithm + ":" + keyID
|
||||
if wantSet[keyIDWithAlgo] {
|
||||
result[keyIDWithAlgo] = json.RawMessage(keyJSONStr)
|
||||
result[keyIDWithAlgo] = jsoniter.RawMessage(keyJSONStr)
|
||||
}
|
||||
}
|
||||
return result, rows.Err()
|
||||
|
|
@ -178,7 +178,7 @@ func (s *oneTimeKeysStatements) InsertOneTimeKeys(ctx context.Context, txn *sql.
|
|||
|
||||
func (s *oneTimeKeysStatements) SelectAndDeleteOneTimeKey(
|
||||
ctx context.Context, txn *sql.Tx, userID, deviceID, algorithm string,
|
||||
) (map[string]json.RawMessage, error) {
|
||||
) (map[string]jsoniter.RawMessage, error) {
|
||||
var keyID string
|
||||
var keyJSON string
|
||||
err := sqlutil.TxStmtContext(ctx, txn, s.selectKeyByAlgorithmStmt).QueryRowContext(ctx, userID, deviceID, algorithm).Scan(&keyID, &keyJSON)
|
||||
|
|
@ -189,7 +189,7 @@ func (s *oneTimeKeysStatements) SelectAndDeleteOneTimeKey(
|
|||
return nil, err
|
||||
}
|
||||
_, err = sqlutil.TxStmtContext(ctx, txn, s.deleteOneTimeKeyStmt).ExecContext(ctx, userID, deviceID, algorithm, keyID)
|
||||
return map[string]json.RawMessage{
|
||||
algorithm + ":" + keyID: json.RawMessage(keyJSON),
|
||||
return map[string]jsoniter.RawMessage{
|
||||
algorithm + ":" + keyID: jsoniter.RawMessage(keyJSON),
|
||||
}, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package shared
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
"github.com/matrix-org/dendrite/keyserver/api"
|
||||
|
|
@ -34,7 +34,7 @@ type Database struct {
|
|||
StaleDeviceListsTable tables.StaleDeviceLists
|
||||
}
|
||||
|
||||
func (d *Database) ExistingOneTimeKeys(ctx context.Context, userID, deviceID string, keyIDsWithAlgorithms []string) (map[string]json.RawMessage, error) {
|
||||
func (d *Database) ExistingOneTimeKeys(ctx context.Context, userID, deviceID string, keyIDsWithAlgorithms []string) (map[string]jsoniter.RawMessage, error) {
|
||||
return d.OneTimeKeysTable.SelectOneTimeKeys(ctx, userID, deviceID, keyIDsWithAlgorithms)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package sqlite3
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
|
|
@ -93,7 +93,7 @@ func NewSqliteOneTimeKeysTable(db *sql.DB) (tables.OneTimeKeys, error) {
|
|||
return s, nil
|
||||
}
|
||||
|
||||
func (s *oneTimeKeysStatements) SelectOneTimeKeys(ctx context.Context, userID, deviceID string, keyIDsWithAlgorithms []string) (map[string]json.RawMessage, error) {
|
||||
func (s *oneTimeKeysStatements) SelectOneTimeKeys(ctx context.Context, userID, deviceID string, keyIDsWithAlgorithms []string) (map[string]jsoniter.RawMessage, error) {
|
||||
rows, err := s.selectKeysStmt.QueryContext(ctx, userID, deviceID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -105,7 +105,7 @@ func (s *oneTimeKeysStatements) SelectOneTimeKeys(ctx context.Context, userID, d
|
|||
wantSet[ka] = true
|
||||
}
|
||||
|
||||
result := make(map[string]json.RawMessage)
|
||||
result := make(map[string]jsoniter.RawMessage)
|
||||
for rows.Next() {
|
||||
var keyID string
|
||||
var algorithm string
|
||||
|
|
@ -115,7 +115,7 @@ func (s *oneTimeKeysStatements) SelectOneTimeKeys(ctx context.Context, userID, d
|
|||
}
|
||||
keyIDWithAlgo := algorithm + ":" + keyID
|
||||
if wantSet[keyIDWithAlgo] {
|
||||
result[keyIDWithAlgo] = json.RawMessage(keyJSONStr)
|
||||
result[keyIDWithAlgo] = jsoniter.RawMessage(keyJSONStr)
|
||||
}
|
||||
}
|
||||
return result, rows.Err()
|
||||
|
|
@ -180,7 +180,7 @@ func (s *oneTimeKeysStatements) InsertOneTimeKeys(
|
|||
|
||||
func (s *oneTimeKeysStatements) SelectAndDeleteOneTimeKey(
|
||||
ctx context.Context, txn *sql.Tx, userID, deviceID, algorithm string,
|
||||
) (map[string]json.RawMessage, error) {
|
||||
) (map[string]jsoniter.RawMessage, error) {
|
||||
var keyID string
|
||||
var keyJSON string
|
||||
err := sqlutil.TxStmtContext(ctx, txn, s.selectKeyByAlgorithmStmt).QueryRowContext(ctx, userID, deviceID, algorithm).Scan(&keyID, &keyJSON)
|
||||
|
|
@ -197,7 +197,7 @@ func (s *oneTimeKeysStatements) SelectAndDeleteOneTimeKey(
|
|||
if keyJSON == "" {
|
||||
return nil, nil
|
||||
}
|
||||
return map[string]json.RawMessage{
|
||||
algorithm + ":" + keyID: json.RawMessage(keyJSON),
|
||||
return map[string]jsoniter.RawMessage{
|
||||
algorithm + ":" + keyID: jsoniter.RawMessage(keyJSON),
|
||||
}, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,19 +17,18 @@ package tables
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/matrix-org/dendrite/keyserver/api"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
)
|
||||
|
||||
type OneTimeKeys interface {
|
||||
SelectOneTimeKeys(ctx context.Context, userID, deviceID string, keyIDsWithAlgorithms []string) (map[string]json.RawMessage, error)
|
||||
SelectOneTimeKeys(ctx context.Context, userID, deviceID string, keyIDsWithAlgorithms []string) (map[string]jsoniter.RawMessage, error)
|
||||
CountOneTimeKeys(ctx context.Context, userID, deviceID string) (*api.OneTimeKeysCount, error)
|
||||
InsertOneTimeKeys(ctx context.Context, txn *sql.Tx, keys api.OneTimeKeys) (*api.OneTimeKeysCount, error)
|
||||
// SelectAndDeleteOneTimeKey selects a single one time key matching the user/device/algorithm specified and returns the algo:key_id => JSON.
|
||||
// Returns an empty map if the key does not exist.
|
||||
SelectAndDeleteOneTimeKey(ctx context.Context, txn *sql.Tx, userID, deviceID, algorithm string) (map[string]json.RawMessage, error)
|
||||
SelectAndDeleteOneTimeKey(ctx context.Context, txn *sql.Tx, userID, deviceID, algorithm string) (map[string]jsoniter.RawMessage, error)
|
||||
}
|
||||
|
||||
type DeviceKeys interface {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package routing
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime"
|
||||
|
|
@ -146,12 +146,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 := jsoniter.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, _ = jsoniter.Marshal(res.JSON)
|
||||
}
|
||||
|
||||
// Set status code and write the body
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package acls
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
|
|
@ -88,7 +88,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 := jsoniter.Unmarshal(state.Content(), &acls.ServerACL); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to unmarshal state content for server ACLs")
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
|
||||
fsAPI "github.com/matrix-org/dendrite/federationsender/api"
|
||||
|
|
@ -306,7 +306,7 @@ func (t *RoomserverInternalAPITrace) QueryServerBannedFromRoom(ctx context.Conte
|
|||
}
|
||||
|
||||
func js(thing interface{}) string {
|
||||
b, err := json.Marshal(thing)
|
||||
b, err := jsoniter.Marshal(thing)
|
||||
if err != nil {
|
||||
return fmt.Sprintf("Marshal error:%s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ func (p *PerformError) JSONResponse() util.JSONResponse {
|
|||
return util.JSONResponse{
|
||||
Code: p.RemoteCode,
|
||||
// TODO: Should we assert this is in fact JSON? E.g gjson parse?
|
||||
JSON: json.RawMessage(p.Msg),
|
||||
JSON: jsoniter.RawMessage(p.Msg),
|
||||
}
|
||||
default:
|
||||
return util.ErrorResponse(p)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
|
|
@ -351,12 +351,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 jsoniter.Marshal(se)
|
||||
}
|
||||
|
||||
func (r *QueryBulkStateContentResponse) UnmarshalJSON(data []byte) error {
|
||||
wireFormat := make(map[string]string)
|
||||
err := json.Unmarshal(data, &wireFormat)
|
||||
err := jsoniter.Unmarshal(data, &wireFormat)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -382,12 +382,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 jsoniter.Marshal(se)
|
||||
}
|
||||
|
||||
func (r *QueryCurrentStateResponse) UnmarshalJSON(data []byte) error {
|
||||
res := make(map[string]*gomatrixserverlib.HeaderedEvent)
|
||||
err := json.Unmarshal(data, &res)
|
||||
err := jsoniter.Unmarshal(data, &res)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
)
|
||||
|
|
@ -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 := jsoniter.Unmarshal(ev.Content(), &content); err != nil {
|
||||
break // value is not understood
|
||||
}
|
||||
for _, s := range knownStates {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package internal
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
|
@ -198,11 +198,11 @@ func (r *RoomserverInternalAPI) sendUpdatedAliasesEvent(
|
|||
return err
|
||||
}
|
||||
content := roomAliasesContent{Aliases: aliases}
|
||||
rawContent, err := json.Marshal(content)
|
||||
rawContent, err := jsoniter.Marshal(content)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = builder.SetContent(json.RawMessage(rawContent))
|
||||
err = builder.SetContent(jsoniter.RawMessage(rawContent))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package input
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
|
@ -73,7 +73,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 := jsoniter.Marshal(updates[i])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package perform
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
|
|
@ -166,7 +166,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 = jsoniter.Unmarshal(ev.Content(), &content); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("json.Unmarshal for history visibility failed")
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package query
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"testing"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal/test"
|
||||
|
|
@ -49,7 +49,7 @@ func (db *getEventDB) addFakeEvent(eventID string, authIDs []string) error {
|
|||
"auth_events": authEvents,
|
||||
}
|
||||
|
||||
eventJSON, err := json.Marshal(&builder)
|
||||
eventJSON, err := jsoniter.Marshal(&builder)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package inthttp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
|
@ -17,7 +17,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("inputRoomEvents", func(req *http.Request) util.JSONResponse {
|
||||
var request api.InputRoomEventsRequest
|
||||
var response api.InputRoomEventsResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
r.InputRoomEvents(req.Context(), &request, &response)
|
||||
|
|
@ -28,7 +28,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("performInvite", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformInviteRequest
|
||||
var response api.PerformInviteResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := r.PerformInvite(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -41,7 +41,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("performJoin", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformJoinRequest
|
||||
var response api.PerformJoinResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
r.PerformJoin(req.Context(), &request, &response)
|
||||
|
|
@ -52,7 +52,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("performLeave", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformLeaveRequest
|
||||
var response api.PerformLeaveResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := r.PerformLeave(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -65,7 +65,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("performPeek", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformPeekRequest
|
||||
var response api.PerformPeekResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
r.PerformPeek(req.Context(), &request, &response)
|
||||
|
|
@ -76,7 +76,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("performPublish", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformPublishRequest
|
||||
var response api.PerformPublishResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
r.PerformPublish(req.Context(), &request, &response)
|
||||
|
|
@ -88,7 +88,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryPublishedRooms", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryPublishedRoomsRequest
|
||||
var response api.QueryPublishedRoomsResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryPublishedRooms(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -102,7 +102,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryLatestEventsAndState", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryLatestEventsAndStateRequest
|
||||
var response api.QueryLatestEventsAndStateResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryLatestEventsAndState(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -116,7 +116,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryStateAfterEvents", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryStateAfterEventsRequest
|
||||
var response api.QueryStateAfterEventsResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryStateAfterEvents(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -130,7 +130,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryMissingAuthPrevEvents", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryMissingAuthPrevEventsRequest
|
||||
var response api.QueryMissingAuthPrevEventsResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryMissingAuthPrevEvents(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -144,7 +144,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryEventsByID", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryEventsByIDRequest
|
||||
var response api.QueryEventsByIDResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryEventsByID(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -158,7 +158,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("QueryMembershipForUser", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryMembershipForUserRequest
|
||||
var response api.QueryMembershipForUserResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryMembershipForUser(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -172,7 +172,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryMembershipsForRoom", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryMembershipsForRoomRequest
|
||||
var response api.QueryMembershipsForRoomResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryMembershipsForRoom(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -186,7 +186,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryServerJoinedToRoom", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryServerJoinedToRoomRequest
|
||||
var response api.QueryServerJoinedToRoomResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryServerJoinedToRoom(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -200,7 +200,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryServerAllowedToSeeEvent", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryServerAllowedToSeeEventRequest
|
||||
var response api.QueryServerAllowedToSeeEventResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryServerAllowedToSeeEvent(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -214,7 +214,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryMissingEvents", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryMissingEventsRequest
|
||||
var response api.QueryMissingEventsResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryMissingEvents(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -228,7 +228,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryStateAndAuthChain", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryStateAndAuthChainRequest
|
||||
var response api.QueryStateAndAuthChainResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryStateAndAuthChain(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -242,7 +242,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("PerformBackfill", func(req *http.Request) util.JSONResponse {
|
||||
var request api.PerformBackfillRequest
|
||||
var response api.PerformBackfillResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.PerformBackfill(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -256,7 +256,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("QueryRoomVersionCapabilities", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryRoomVersionCapabilitiesRequest
|
||||
var response api.QueryRoomVersionCapabilitiesResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryRoomVersionCapabilities(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -270,7 +270,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("QueryRoomVersionForRoom", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryRoomVersionForRoomRequest
|
||||
var response api.QueryRoomVersionForRoomResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryRoomVersionForRoom(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -284,7 +284,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("setRoomAlias", func(req *http.Request) util.JSONResponse {
|
||||
var request api.SetRoomAliasRequest
|
||||
var response api.SetRoomAliasResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.SetRoomAlias(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -298,7 +298,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("GetRoomIDForAlias", func(req *http.Request) util.JSONResponse {
|
||||
var request api.GetRoomIDForAliasRequest
|
||||
var response api.GetRoomIDForAliasResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.GetRoomIDForAlias(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -312,7 +312,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("GetCreatorIDForAlias", func(req *http.Request) util.JSONResponse {
|
||||
var request api.GetCreatorIDForAliasRequest
|
||||
var response api.GetCreatorIDForAliasResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.GetCreatorIDForAlias(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -326,7 +326,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("getAliasesForRoomID", func(req *http.Request) util.JSONResponse {
|
||||
var request api.GetAliasesForRoomIDRequest
|
||||
var response api.GetAliasesForRoomIDResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.GetAliasesForRoomID(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -340,7 +340,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("removeRoomAlias", func(req *http.Request) util.JSONResponse {
|
||||
var request api.RemoveRoomAliasRequest
|
||||
var response api.RemoveRoomAliasResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.RemoveRoomAlias(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -353,7 +353,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryCurrentState", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QueryCurrentStateRequest{}
|
||||
response := api.QueryCurrentStateResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := r.QueryCurrentState(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -366,7 +366,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryRoomsForUser", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QueryRoomsForUserRequest{}
|
||||
response := api.QueryRoomsForUserResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := r.QueryRoomsForUser(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -379,7 +379,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryBulkStateContent", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QueryBulkStateContentRequest{}
|
||||
response := api.QueryBulkStateContentResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := r.QueryBulkStateContent(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -392,7 +392,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("querySharedUsers", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QuerySharedUsersRequest{}
|
||||
response := api.QuerySharedUsersResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := r.QuerySharedUsers(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -405,7 +405,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryKnownUsers", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QueryKnownUsersRequest{}
|
||||
response := api.QueryKnownUsersResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := r.QueryKnownUsers(req.Context(), &request, &response); err != nil {
|
||||
|
|
@ -418,7 +418,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
httputil.MakeInternalAPI("queryServerBannedFromRoom", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QueryServerBannedFromRoomRequest{}
|
||||
response := api.QueryServerBannedFromRoomResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := r.QueryServerBannedFromRoom(req.Context(), &request, &response); err != nil {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"crypto/ed25519"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
|
|
@ -46,10 +46,10 @@ func (p *dummyProducer) SendMessage(msg *sarama.ProducerMessage) (partition int3
|
|||
return 0, 0, nil
|
||||
}
|
||||
be := msg.Value.(sarama.ByteEncoder)
|
||||
b := json.RawMessage(be)
|
||||
b := jsoniter.RawMessage(be)
|
||||
fmt.Println("SENDING >>>>>>>> ", string(b))
|
||||
var out api.OutputEvent
|
||||
err = json.Unmarshal(b, &out)
|
||||
err = jsoniter.Unmarshal(b, &out)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package shared
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
|
|
@ -602,7 +602,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 = jsoniter.Unmarshal(event.Content(), &createContent); err != nil {
|
||||
return gomatrixserverlib.RoomVersion(""), err
|
||||
}
|
||||
// A room version was specified in the event content?
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package sqlite3
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
|
|
@ -488,6 +488,6 @@ func (s *eventStatements) SelectRoomNIDForEventNID(
|
|||
}
|
||||
|
||||
func eventNIDsAsArray(eventNIDs []types.EventNID) string {
|
||||
b, _ := json.Marshal(eventNIDs)
|
||||
b, _ := jsoniter.Marshal(eventNIDs)
|
||||
return string(b)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package sqlite3
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
|
@ -137,7 +137,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 = jsoniter.Unmarshal([]byte(latestNIDsJSON), &latestNIDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
info.IsStub = len(latestNIDs) == 0
|
||||
|
|
@ -180,7 +180,7 @@ func (s *roomStatements) SelectLatestEventNIDs(
|
|||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if err := json.Unmarshal([]byte(nidsJSON), &eventNIDs); err != nil {
|
||||
if err := jsoniter.Unmarshal([]byte(nidsJSON), &eventNIDs); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return eventNIDs, types.StateSnapshotNID(stateSnapshotNID), nil
|
||||
|
|
@ -198,7 +198,7 @@ func (s *roomStatements) SelectLatestEventsNIDsForUpdate(
|
|||
if err != nil {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
if err := json.Unmarshal([]byte(nidsJSON), &eventNIDs); err != nil {
|
||||
if err := jsoniter.Unmarshal([]byte(nidsJSON), &eventNIDs); err != nil {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
return eventNIDs, types.EventNID(lastEventSentNID), types.StateSnapshotNID(stateSnapshotNID), nil
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package sqlite3
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
|
|
@ -72,7 +72,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 := jsoniter.Marshal(stateBlockNIDs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -115,7 +115,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 := jsoniter.Unmarshal([]byte(stateBlockNIDsJSON), &result.StateBlockNIDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package inthttp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
|
@ -16,7 +16,7 @@ func AddRoutes(s api.SigningKeyServerAPI, internalAPIMux *mux.Router, cache cach
|
|||
httputil.MakeInternalAPI("queryPublicKeys", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QueryPublicKeysRequest{}
|
||||
response := api.QueryPublicKeysResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
keys, err := s.FetchKeys(req.Context(), request.Requests)
|
||||
|
|
@ -31,7 +31,7 @@ func AddRoutes(s api.SigningKeyServerAPI, internalAPIMux *mux.Router, cache cach
|
|||
httputil.MakeInternalAPI("inputPublicKeys", func(req *http.Request) util.JSONResponse {
|
||||
request := api.InputPublicKeysRequest{}
|
||||
response := api.InputPublicKeysResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
if err := jsoniter.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := s.StoreKeys(req.Context(), request.Keys); err != nil {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"crypto/ed25519"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
|
@ -119,7 +119,7 @@ func (m *MockRoundTripper) RoundTrip(req *http.Request) (res *http.Response, err
|
|||
|
||||
// Get the keys and JSON-ify them.
|
||||
keys := routing.LocalKeys(s.fedconfig)
|
||||
body, err := json.MarshalIndent(keys.JSON, "", " ")
|
||||
body, err := jsoniter.MarshalIndent(keys.JSON, "", " ")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package consumers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
|
|
@ -70,7 +70,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 := jsoniter.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
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package consumers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/matrix-org/dendrite/eduserver/api"
|
||||
|
|
@ -73,7 +73,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 := jsoniter.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
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
package consumers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/matrix-org/dendrite/eduserver/api"
|
||||
|
|
@ -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 := jsoniter.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
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package consumers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"sync"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
|
|
@ -99,7 +99,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 := jsoniter.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
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package consumers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
|
|
@ -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 := jsoniter.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
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ func PutFilter(
|
|||
}
|
||||
}
|
||||
|
||||
if err = json.Unmarshal(body, &filter); err != nil {
|
||||
if err = jsoniter.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()),
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package postgres
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
|
|
@ -236,12 +236,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 jsoniter.Unmarshal(event.Content(), &content) != nil {
|
||||
// Set containsURL to true if url is present
|
||||
_, containsURL = content["url"]
|
||||
}
|
||||
|
||||
headeredJSON, err := json.Marshal(event)
|
||||
headeredJSON, err := jsoniter.Marshal(event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -284,7 +284,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 := jsoniter.Unmarshal(eventBytes, &ev); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, ev)
|
||||
|
|
@ -305,7 +305,7 @@ func (s *currentRoomStateStatements) SelectStateEvent(
|
|||
return nil, err
|
||||
}
|
||||
var ev gomatrixserverlib.HeaderedEvent
|
||||
if err = json.Unmarshal(res, &ev); err != nil {
|
||||
if err = jsoniter.Unmarshal(res, &ev); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ev, err
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package postgres
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/matrix-org/dendrite/syncapi/storage/tables"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
|
@ -84,7 +84,7 @@ func (s *filterStatements) SelectFilter(
|
|||
|
||||
// Unmarshal JSON into Filter struct
|
||||
var filter gomatrixserverlib.Filter
|
||||
if err = json.Unmarshal(filterData, &filter); err != nil {
|
||||
if err = jsoniter.Unmarshal(filterData, &filter); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &filter, nil
|
||||
|
|
@ -96,7 +96,7 @@ func (s *filterStatements) InsertFilter(
|
|||
var existingFilterID string
|
||||
|
||||
// Serialise json
|
||||
filterJSON, err := json.Marshal(filter)
|
||||
filterJSON, err := jsoniter.Marshal(filter)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package postgres
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
|
|
@ -94,7 +94,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 = jsoniter.Marshal(inviteEvent)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ func (s *inviteEventsStatements) SelectInviteEventsInRange(
|
|||
}
|
||||
|
||||
var event gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(eventJSON, &event); err != nil {
|
||||
if err := jsoniter.Unmarshal(eventJSON, &event); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package postgres
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"sort"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
|
|
@ -167,7 +167,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 := jsoniter.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 := jsoniter.Unmarshal(eventBytes, &ev); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
needSet := stateNeeded[ev.RoomID()]
|
||||
|
|
@ -288,13 +288,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 jsoniter.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 = jsoniter.Marshal(event)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -425,7 +425,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 := jsoniter.Unmarshal(eventBytes, &ev); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package postgres
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
|
|
@ -143,7 +143,7 @@ func (s *sendToDeviceStatements) SelectSendToDeviceMessages(
|
|||
UserID: userID,
|
||||
DeviceID: deviceID,
|
||||
}
|
||||
if err = json.Unmarshal([]byte(content), &event.SendToDeviceEvent); err != nil {
|
||||
if err = jsoniter.Unmarshal([]byte(content), &event.SendToDeviceEvent); err != nil {
|
||||
return
|
||||
}
|
||||
if sentByToken != nil {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package shared
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
|
@ -546,7 +546,7 @@ func (d *Database) addTypingDeltaToResponse(
|
|||
ev := gomatrixserverlib.ClientEvent{
|
||||
Type: gomatrixserverlib.MTyping,
|
||||
}
|
||||
ev.Content, err = json.Marshal(map[string]interface{}{
|
||||
ev.Content, err = jsoniter.Marshal(map[string]interface{}{
|
||||
"user_ids": typingUsers,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -1280,7 +1280,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 := jsoniter.Marshal(event)
|
||||
if err != nil {
|
||||
return streamPos, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package sqlite3
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"strings"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
|
|
@ -225,12 +225,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 jsoniter.Unmarshal(event.Content(), &content) != nil {
|
||||
// Set containsURL to true if url is present
|
||||
_, containsURL = content["url"]
|
||||
}
|
||||
|
||||
headeredJSON, err := json.Marshal(event)
|
||||
headeredJSON, err := jsoniter.Marshal(event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -295,7 +295,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 := jsoniter.Unmarshal(eventBytes, &ev); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, ev)
|
||||
|
|
@ -316,7 +316,7 @@ func (s *currentRoomStateStatements) SelectStateEvent(
|
|||
return nil, err
|
||||
}
|
||||
var ev gomatrixserverlib.HeaderedEvent
|
||||
if err = json.Unmarshal(res, &ev); err != nil {
|
||||
if err = jsoniter.Unmarshal(res, &ev); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ev, err
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package sqlite3
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
|
||||
"github.com/matrix-org/dendrite/syncapi/storage/tables"
|
||||
|
|
@ -88,7 +88,7 @@ func (s *filterStatements) SelectFilter(
|
|||
|
||||
// Unmarshal JSON into Filter struct
|
||||
var filter gomatrixserverlib.Filter
|
||||
if err = json.Unmarshal(filterData, &filter); err != nil {
|
||||
if err = jsoniter.Unmarshal(filterData, &filter); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &filter, nil
|
||||
|
|
@ -100,7 +100,7 @@ func (s *filterStatements) InsertFilter(
|
|||
var existingFilterID string
|
||||
|
||||
// Serialise json
|
||||
filterJSON, err := json.Marshal(filter)
|
||||
filterJSON, err := jsoniter.Marshal(filter)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package sqlite3
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
|
|
@ -99,7 +99,7 @@ func (s *inviteEventsStatements) InsertInviteEvent(
|
|||
}
|
||||
|
||||
var headeredJSON []byte
|
||||
headeredJSON, err = json.Marshal(inviteEvent)
|
||||
headeredJSON, err = jsoniter.Marshal(inviteEvent)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ func (s *inviteEventsStatements) SelectInviteEventsInRange(
|
|||
}
|
||||
|
||||
var event gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(eventJSON, &event); err != nil {
|
||||
if err := jsoniter.Unmarshal(eventJSON, &event); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if deleted {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package sqlite3
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"sort"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
|
|
@ -160,7 +160,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 := jsoniter.Marshal(event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -230,7 +230,7 @@ func (s *outputRoomEventsStatements) SelectStateInRange(
|
|||
|
||||
// TODO: Handle redacted events
|
||||
var ev gomatrixserverlib.HeaderedEvent
|
||||
if err := json.Unmarshal(eventBytes, &ev); err != nil {
|
||||
if err := jsoniter.Unmarshal(eventBytes, &ev); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
needSet := stateNeeded[ev.RoomID()]
|
||||
|
|
@ -287,22 +287,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 jsoniter.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 := jsoniter.Marshal(event)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
addStateJSON, err := json.Marshal(addState)
|
||||
addStateJSON, err := jsoniter.Marshal(addState)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
removeStateJSON, err := json.Marshal(removeState)
|
||||
removeStateJSON, err := jsoniter.Marshal(removeState)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
|
@ -440,7 +440,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 := jsoniter.Unmarshal(eventBytes, &ev); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
@ -463,12 +463,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 = jsoniter.Unmarshal([]byte(addIDsJSON), &addIDs); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(delIDsJSON) > 0 {
|
||||
if err = json.Unmarshal([]byte(delIDsJSON), &delIDs); err != nil {
|
||||
if err = jsoniter.Unmarshal([]byte(delIDsJSON), &delIDs); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package sqlite3
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"strings"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
|
|
@ -136,7 +136,7 @@ func (s *sendToDeviceStatements) SelectSendToDeviceMessages(
|
|||
UserID: userID,
|
||||
DeviceID: deviceID,
|
||||
}
|
||||
if err = json.Unmarshal([]byte(content), &event.SendToDeviceEvent); err != nil {
|
||||
if err = jsoniter.Unmarshal([]byte(content), &event.SendToDeviceEvent); err != nil {
|
||||
return
|
||||
}
|
||||
if sentByToken != nil {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package storage_test
|
|||
import (
|
||||
"context"
|
||||
"crypto/ed25519"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
|
@ -550,7 +550,7 @@ func TestSendToDeviceBehaviour(t *testing.T) {
|
|||
streamPos, err := db.StoreNewSendForDeviceMessage(ctx, types.StreamPosition(0), "alice", "one", gomatrixserverlib.SendToDeviceEvent{
|
||||
Sender: "bob",
|
||||
Type: "m.type",
|
||||
Content: json.RawMessage("{}"),
|
||||
Content: jsoniter.RawMessage("{}"),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package sync
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"fmt"
|
||||
"sync"
|
||||
"testing"
|
||||
|
|
@ -49,7 +49,7 @@ var (
|
|||
|
||||
func init() {
|
||||
var err error
|
||||
err = json.Unmarshal([]byte(`{
|
||||
err = jsoniter.Unmarshal([]byte(`{
|
||||
"_room_version": "1",
|
||||
"type": "m.room.message",
|
||||
"content": {
|
||||
|
|
@ -65,7 +65,7 @@ func init() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = json.Unmarshal([]byte(`{
|
||||
err = jsoniter.Unmarshal([]byte(`{
|
||||
"_room_version": "1",
|
||||
"type": "m.room.member",
|
||||
"state_key": "`+bob+`",
|
||||
|
|
@ -81,7 +81,7 @@ func init() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = json.Unmarshal([]byte(`{
|
||||
err = jsoniter.Unmarshal([]byte(`{
|
||||
"_room_version": "1",
|
||||
"type": "m.room.member",
|
||||
"state_key": "`+bob+`",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ package sync
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
|
@ -75,7 +75,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 := jsoniter.Unmarshal([]byte(filterQuery), &f)
|
||||
if err == nil && f.Room.Timeline.Limit != nil {
|
||||
timelineLimit = *f.Room.Timeline.Limit
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/json-iterator/go"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -372,7 +372,7 @@ func (p *syncToken) String() string {
|
|||
|
||||
// PrevEventRef represents a reference to a previous event in a state event upgrade
|
||||
type PrevEventRef struct {
|
||||
PrevContent json.RawMessage `json:"prev_content"`
|
||||
PrevContent jsoniter.RawMessage `json:"prev_content"`
|
||||
ReplacesState string `json:"replaces_state"`
|
||||
PrevSender string `json:"prev_sender"`
|
||||
}
|
||||
|
|
@ -466,20 +466,20 @@ func NewJoinResponse() *JoinResponse {
|
|||
// InviteResponse represents a /sync response for a room which is under the 'invite' key.
|
||||
type InviteResponse struct {
|
||||
InviteState struct {
|
||||
Events []json.RawMessage `json:"events"`
|
||||
Events []jsoniter.RawMessage `json:"events"`
|
||||
} `json:"invite_state"`
|
||||
}
|
||||
|
||||
// NewInviteResponse creates an empty response with initialised arrays.
|
||||
func NewInviteResponse(event gomatrixserverlib.HeaderedEvent) *InviteResponse {
|
||||
res := InviteResponse{}
|
||||
res.InviteState.Events = []json.RawMessage{}
|
||||
res.InviteState.Events = []jsoniter.RawMessage{}
|
||||
|
||||
// First see if there's invite_room_state in the unsigned key of the invite.
|
||||
// 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)
|
||||
_ = jsoniter.Unmarshal([]byte(inviteRoomState.Raw), &res.InviteState.Events)
|
||||
}
|
||||
|
||||
// Then we'll see if we can create a partial of the invite event itself.
|
||||
|
|
@ -487,7 +487,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 := jsoniter.Marshal(inviteEvent); err == nil {
|
||||
res.InviteState.Events = append(res.InviteState.Events, ev)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ func TestNewInviteResponse(t *testing.T) {
|
|||
}
|
||||
|
||||
res := NewInviteResponse(ev.Headered(gomatrixserverlib.RoomVersionV5))
|
||||
j, err := json.Marshal(res)
|
||||
j, err := jsoniter.Marshal(res)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue