summary refs log tree commit diff
path: root/synapse/storage/pusher.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-16 11:01:09 +0100
committerErik Johnston <erik@matrix.org>2015-04-16 11:01:09 +0100
commitbc9e69e16099142acdb06c3ea7c7ef9aec9e4ec9 (patch)
tree568ca9520c7eea5b00a90ea305bfc495e7ee85b1 /synapse/storage/pusher.py
parentRemove mysql/maria support (diff)
downloadsynapse-bc9e69e16099142acdb06c3ea7c7ef9aec9e4ec9.tar.xz
Move encoding and decoding of JSON into storage layer
Diffstat (limited to 'synapse/storage/pusher.py')
-rw-r--r--synapse/storage/pusher.py26
1 files changed, 6 insertions, 20 deletions
diff --git a/synapse/storage/pusher.py b/synapse/storage/pusher.py
index 80c3ba154f..5c1c3d32e6 100644
--- a/synapse/storage/pusher.py
+++ b/synapse/storage/pusher.py
@@ -20,7 +20,10 @@ from twisted.internet import defer
 
 from synapse.api.errors import StoreError
 
+from syutil.jsonutil import encode_canonical_json
+
 import logging
+import simplejson as json
 
 logger = logging.getLogger(__name__)
 
@@ -52,7 +55,7 @@ class PusherStore(SQLBaseStore):
                 "device_display_name": r[6],
                 "pushkey": r[7],
                 "pushkey_ts": r[8],
-                "data": r[9],
+                "data": json.loads(r[9]),
                 "last_token": r[10],
                 "last_success": r[11],
                 "failing_since": r[12]
@@ -84,7 +87,7 @@ class PusherStore(SQLBaseStore):
                 "device_display_name": r[6],
                 "pushkey": r[7],
                 "pushkey_ts": r[8],
-                "data": r[9],
+                "data": json.loads(r[9]),
                 "last_token": r[10],
                 "last_success": r[11],
                 "failing_since": r[12]
@@ -114,7 +117,7 @@ class PusherStore(SQLBaseStore):
                     device_display_name=device_display_name,
                     ts=pushkey_ts,
                     lang=lang,
-                    data=data
+                    data=encode_canonical_json(data).decode("UTF-8"),
                 ),
                 insertion_values=dict(
                     id=next_id,
@@ -165,20 +168,3 @@ class PusherStore(SQLBaseStore):
 class PushersTable(Table):
     table_name = "pushers"
 
-    fields = [
-        "id",
-        "user_name",
-        "kind",
-        "profile_tag",
-        "app_id",
-        "app_display_name",
-        "device_display_name",
-        "pushkey",
-        "pushkey_ts",
-        "data",
-        "last_token",
-        "last_success",
-        "failing_since"
-    ]
-
-    EntryType = collections.namedtuple("PusherEntry", fields)