mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-28 21:22:02 +00:00
commit
54fdbc7e50
@ -19,7 +19,7 @@ from twisted.internet.protocol import Factory
|
||||
from twisted.internet import defer, reactor
|
||||
from synapse.http.endpoint import matrix_federation_endpoint
|
||||
from synapse.util.logcontext import PreserveLoggingContext
|
||||
import json
|
||||
import simplejson as json
|
||||
import logging
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from synapse.util.frozenutils import freeze, unfreeze
|
||||
from synapse.util.frozenutils import freeze
|
||||
|
||||
|
||||
class _EventInternalMetadata(object):
|
||||
@ -140,10 +140,6 @@ class FrozenEvent(EventBase):
|
||||
|
||||
return e
|
||||
|
||||
def get_dict(self):
|
||||
# We need to unfreeze what we return
|
||||
return unfreeze(super(FrozenEvent, self).get_dict())
|
||||
|
||||
def __str__(self):
|
||||
return self.__repr__()
|
||||
|
||||
|
@ -23,7 +23,8 @@ from twisted.internet import defer
|
||||
|
||||
from synapse.util.logutils import log_function
|
||||
|
||||
import json
|
||||
from syutil.jsonutil import encode_canonical_json
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
@ -70,7 +71,7 @@ class TransactionActions(object):
|
||||
transaction.transaction_id,
|
||||
transaction.origin,
|
||||
code,
|
||||
json.dumps(response)
|
||||
encode_canonical_json(response)
|
||||
)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
@ -100,5 +101,5 @@ class TransactionActions(object):
|
||||
transaction.transaction_id,
|
||||
transaction.destination,
|
||||
response_code,
|
||||
json.dumps(response_dict)
|
||||
encode_canonical_json(response_dict)
|
||||
)
|
||||
|
@ -20,7 +20,7 @@ from synapse.api.errors import Codes, SynapseError
|
||||
from synapse.util.logutils import log_function
|
||||
|
||||
import logging
|
||||
import json
|
||||
import simplejson as json
|
||||
import re
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@ from synapse.api.errors import (
|
||||
from synapse.api.constants import EventTypes, Membership, RejectedReason
|
||||
from synapse.util.logutils import log_function
|
||||
from synapse.util.async import run_on_reactor
|
||||
from synapse.util.frozenutils import unfreeze
|
||||
from synapse.crypto.event_signing import (
|
||||
compute_event_signature, add_hashes_and_signatures,
|
||||
)
|
||||
@ -311,7 +312,7 @@ class FederationHandler(BaseHandler):
|
||||
self.room_queues[room_id] = []
|
||||
|
||||
builder = self.event_builder_factory.new(
|
||||
event.get_pdu_json()
|
||||
unfreeze(event.get_pdu_json())
|
||||
)
|
||||
|
||||
handled_events = set()
|
||||
|
@ -462,7 +462,7 @@ class RoomMemberHandler(BaseHandler):
|
||||
room_hosts,
|
||||
room_id,
|
||||
event.user_id,
|
||||
event.get_dict()["content"], # FIXME To get a non-frozen dict
|
||||
event.content, # FIXME To get a non-frozen dict
|
||||
context
|
||||
)
|
||||
else:
|
||||
|
@ -23,7 +23,7 @@ from twisted.web.http_headers import Headers
|
||||
|
||||
from StringIO import StringIO
|
||||
|
||||
import json
|
||||
import simplejson as json
|
||||
import logging
|
||||
import urllib
|
||||
|
||||
|
@ -33,7 +33,7 @@ from synapse.api.errors import (
|
||||
|
||||
from syutil.crypto.jsonsign import sign_json
|
||||
|
||||
import json
|
||||
import simplejson as json
|
||||
import logging
|
||||
import urllib
|
||||
import urlparse
|
||||
|
@ -22,7 +22,7 @@ import synapse.util.async
|
||||
import baserules
|
||||
|
||||
import logging
|
||||
import json
|
||||
import simplejson as json
|
||||
import re
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -20,7 +20,7 @@ from httppusher import HttpPusher
|
||||
from synapse.push import PusherConfigException
|
||||
|
||||
import logging
|
||||
import json
|
||||
import simplejson as json
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -4,7 +4,7 @@ from distutils.version import LooseVersion
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
REQUIREMENTS = {
|
||||
"syutil>=0.0.2": ["syutil"],
|
||||
"syutil>=0.0.3": ["syutil"],
|
||||
"matrix_angular_sdk>=0.6.1": ["syweb>=0.6.1"],
|
||||
"Twisted==14.0.2": ["twisted==14.0.2"],
|
||||
"service_identity>=1.0.0": ["service_identity>=1.0.0"],
|
||||
|
@ -20,7 +20,7 @@ from synapse.api.errors import AuthError, SynapseError, Codes
|
||||
from synapse.types import RoomAlias
|
||||
from .base import ClientV1RestServlet, client_path_pattern
|
||||
|
||||
import json
|
||||
import simplejson as json
|
||||
import logging
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ from synapse.api.errors import SynapseError
|
||||
from synapse.types import UserID
|
||||
from base import ClientV1RestServlet, client_path_pattern
|
||||
|
||||
import json
|
||||
import simplejson as json
|
||||
|
||||
|
||||
class LoginRestServlet(ClientV1RestServlet):
|
||||
|
@ -21,7 +21,7 @@ from synapse.api.errors import SynapseError
|
||||
from synapse.types import UserID
|
||||
from .base import ClientV1RestServlet, client_path_pattern
|
||||
|
||||
import json
|
||||
import simplejson as json
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -19,7 +19,7 @@ from twisted.internet import defer
|
||||
from .base import ClientV1RestServlet, client_path_pattern
|
||||
from synapse.types import UserID
|
||||
|
||||
import json
|
||||
import simplejson as json
|
||||
|
||||
|
||||
class ProfileDisplaynameRestServlet(ClientV1RestServlet):
|
||||
|
@ -27,7 +27,7 @@ from synapse.push.rulekinds import (
|
||||
PRIORITY_CLASS_MAP, PRIORITY_CLASS_INVERSE_MAP
|
||||
)
|
||||
|
||||
import json
|
||||
import simplejson as json
|
||||
|
||||
|
||||
class PushRuleRestServlet(ClientV1RestServlet):
|
||||
|
@ -19,7 +19,7 @@ from synapse.api.errors import SynapseError, Codes
|
||||
from synapse.push import PusherConfigException
|
||||
from .base import ClientV1RestServlet, client_path_pattern
|
||||
|
||||
import json
|
||||
import simplejson as json
|
||||
|
||||
|
||||
class PusherRestServlet(ClientV1RestServlet):
|
||||
|
@ -25,7 +25,7 @@ from synapse.util.async import run_on_reactor
|
||||
|
||||
from hashlib import sha1
|
||||
import hmac
|
||||
import json
|
||||
import simplejson as json
|
||||
import logging
|
||||
import urllib
|
||||
|
||||
|
@ -23,7 +23,7 @@ from synapse.api.constants import EventTypes, Membership
|
||||
from synapse.types import UserID, RoomID, RoomAlias
|
||||
from synapse.events.utils import serialize_event
|
||||
|
||||
import json
|
||||
import simplejson as json
|
||||
import logging
|
||||
import urllib
|
||||
|
||||
|
@ -21,7 +21,7 @@ from synapse.types import UserID
|
||||
|
||||
from ._base import client_v2_pattern
|
||||
|
||||
import json
|
||||
import simplejson as json
|
||||
import logging
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ from twisted.web import server, resource
|
||||
from twisted.internet import defer
|
||||
|
||||
import base64
|
||||
import json
|
||||
import simplejson as json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
@ -44,7 +44,6 @@ from syutil.jsonutil import encode_canonical_json
|
||||
from synapse.crypto.event_signing import compute_event_reference_hash
|
||||
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
@ -301,12 +300,16 @@ class DataStore(RoomMemberStore, RoomStore,
|
||||
or_replace=True,
|
||||
)
|
||||
|
||||
content = encode_canonical_json(
|
||||
event.content
|
||||
).decode("UTF-8")
|
||||
|
||||
vals = {
|
||||
"topological_ordering": event.depth,
|
||||
"event_id": event.event_id,
|
||||
"type": event.type,
|
||||
"room_id": event.room_id,
|
||||
"content": json.dumps(event.get_dict()["content"]),
|
||||
"content": content,
|
||||
"processed": True,
|
||||
"outlier": outlier,
|
||||
"depth": event.depth,
|
||||
@ -326,7 +329,10 @@ class DataStore(RoomMemberStore, RoomStore,
|
||||
"prev_events",
|
||||
]
|
||||
}
|
||||
vals["unrecognized_keys"] = json.dumps(unrec)
|
||||
|
||||
vals["unrecognized_keys"] = encode_canonical_json(
|
||||
unrec
|
||||
).decode("UTF-8")
|
||||
|
||||
try:
|
||||
self._simple_insert_txn(
|
||||
|
@ -24,7 +24,7 @@ from synapse.util.lrucache import LruCache
|
||||
from twisted.internet import defer
|
||||
|
||||
import collections
|
||||
import json
|
||||
import simplejson as json
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
@ -17,7 +17,7 @@ from twisted.internet import defer
|
||||
|
||||
from ._base import SQLBaseStore
|
||||
|
||||
import json
|
||||
import simplejson as json
|
||||
|
||||
|
||||
class FilteringStore(SQLBaseStore):
|
||||
|
@ -20,7 +20,7 @@ from twisted.internet import defer
|
||||
|
||||
import logging
|
||||
import copy
|
||||
import json
|
||||
import simplejson as json
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -21,6 +21,9 @@ def freeze(o):
|
||||
if t is dict:
|
||||
return frozendict({k: freeze(v) for k, v in o.items()})
|
||||
|
||||
if t is frozendict:
|
||||
return o
|
||||
|
||||
if t is str or t is unicode:
|
||||
return o
|
||||
|
||||
@ -33,10 +36,11 @@ def freeze(o):
|
||||
|
||||
|
||||
def unfreeze(o):
|
||||
if isinstance(o, frozendict) or isinstance(o, dict):
|
||||
t = type(o)
|
||||
if t is dict or t is frozendict:
|
||||
return dict({k: unfreeze(v) for k, v in o.items()})
|
||||
|
||||
if isinstance(o, basestring):
|
||||
if t is str or t is unicode:
|
||||
return o
|
||||
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user