summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-12-16 13:17:09 +0000
committerErik Johnston <erik@matrix.org>2014-12-16 13:17:09 +0000
commit882dc8dcab434d24b0e902be3b4545ceabe9bdbe (patch)
treecc3f35fc5609c983cc56d2ae48628bcb7522f103 /synapse/storage
parentAdd basic docstring to annotate_context_with_state (diff)
downloadsynapse-882dc8dcab434d24b0e902be3b4545ceabe9bdbe.tar.xz
Persist internal_metadata
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/__init__.py5
-rw-r--r--synapse/storage/_base.py7
-rw-r--r--synapse/storage/schema/im.sql1
3 files changed, 10 insertions, 3 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py
index 5c079da5ba..26f205ae8f 100644
--- a/synapse/storage/__init__.py
+++ b/synapse/storage/__init__.py
@@ -156,12 +156,17 @@ class DataStore(RoomMemberStore, RoomStore,
             ]
         }
 
+        metadata_json =  encode_canonical_json(
+            event.internal_metadata.get_dict()
+        )
+
         self._simple_insert_txn(
             txn,
             table="event_json",
             values={
                 "event_id": event.event_id,
                 "room_id": event.room_id,
+                "internal_metadata": metadata_json.decode("UTF-8"),
                 "json": encode_canonical_json(event_dict).decode("UTF-8"),
             },
             or_replace=True,
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 31d5163c19..6dc857c4aa 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -452,7 +452,7 @@ class SQLBaseStore(object):
     def _get_event_txn(self, txn, event_id, check_redacted=True,
                        get_prev_content=True):
         sql = (
-            "SELECT json, r.event_id FROM event_json as e "
+            "SELECT internal_metadata, json, r.event_id FROM event_json as e "
             "LEFT JOIN redactions as r ON e.event_id = r.redacts "
             "WHERE e.event_id = ? "
             "LIMIT 1 "
@@ -465,11 +465,12 @@ class SQLBaseStore(object):
         if not res:
             return None
 
-        js, redacted = res
+        internal_metadata, js, redacted = res
 
         d = json.loads(js)
+        internal_metadata = json.loads(internal_metadata)
 
-        ev = FrozenEvent(d)
+        ev = FrozenEvent(d, internal_metadata_dict=internal_metadata)
 
         if check_redacted and redacted:
             ev = prune_event(ev)
diff --git a/synapse/storage/schema/im.sql b/synapse/storage/schema/im.sql
index 0300bb29e1..253f9f779b 100644
--- a/synapse/storage/schema/im.sql
+++ b/synapse/storage/schema/im.sql
@@ -36,6 +36,7 @@ CREATE INDEX IF NOT EXISTS events_room_id ON events (room_id);
 CREATE TABLE IF NOT EXISTS event_json(
     event_id TEXT NOT NULL,
     room_id TEXT NOT NULL,
+    internal_metadata NOT NULL,
     json BLOB NOT NULL,
     CONSTRAINT ev_j_uniq UNIQUE (event_id)
 );