summary refs log tree commit diff
path: root/synapse/events/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/events/__init__.py')
-rw-r--r--synapse/events/__init__.py36
1 files changed, 4 insertions, 32 deletions
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py
index d9dfe5e3f3..f8fbb18e3c 100644
--- a/synapse/events/__init__.py
+++ b/synapse/events/__init__.py
@@ -15,37 +15,9 @@
 
 from frozendict import frozendict
 
-import copy
-
-
-def _freeze(o):
-    if isinstance(o, dict) or isinstance(o, frozendict):
-        return frozendict({k: _freeze(v) for k, v in o.items()})
-
-    if isinstance(o, basestring):
-        return o
-
-    try:
-        return tuple([_freeze(i) for i in o])
-    except TypeError:
-        pass
-
-    return o
+from synapse.util.frozenutils import freeze, unfreeze
 
-
-def _unfreeze(o):
-    if isinstance(o, frozendict) or isinstance(o, dict):
-        return dict({k: _unfreeze(v) for k, v in o.items()})
-
-    if isinstance(o, basestring):
-        return o
-
-    try:
-        return [_unfreeze(i) for i in o]
-    except TypeError:
-        pass
-
-    return o
+import copy
 
 
 class _EventInternalMetadata(object):
@@ -147,7 +119,7 @@ class FrozenEvent(EventBase):
         signatures = copy.deepcopy(event_dict.pop("signatures", {}))
         unsigned = copy.deepcopy(event_dict.pop("unsigned", {}))
 
-        frozen_dict = _freeze(event_dict)
+        frozen_dict = freeze(event_dict)
 
         super(FrozenEvent, self).__init__(
             frozen_dict,
@@ -167,7 +139,7 @@ class FrozenEvent(EventBase):
 
     def get_dict(self):
         # We need to unfreeze what we return
-        return _unfreeze(super(FrozenEvent, self).get_dict())
+        return unfreeze(super(FrozenEvent, self).get_dict())
 
     def __str__(self):
         return self.__repr__()