summary refs log tree commit diff
path: root/synapse/storage/_base.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-09-06 02:23:36 +0100
committerErik Johnston <erik@matrix.org>2014-09-06 02:23:36 +0100
commit781ff713ba65e9a8075063ee5112479afcb412ed (patch)
tree1df45adf38713cac9d045c43296f1026897c91c6 /synapse/storage/_base.py
parentDocument new invite key added to createRoom api (diff)
downloadsynapse-781ff713ba65e9a8075063ee5112479afcb412ed.tar.xz
When getting a state event also include the previous content
Diffstat (limited to 'synapse/storage/_base.py')
-rw-r--r--synapse/storage/_base.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index bae50e7d1f..8037225079 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -312,6 +312,25 @@ class SQLBaseStore(object):
             **d
         )
 
+    def _parse_events(self, rows):
+        return self._db_pool.runInteraction(self._parse_events_txn, rows)
+
+    def _parse_events_txn(self, txn, rows):
+        events = [self._parse_event_from_row(r) for r in rows]
+
+        sql = "SELECT * FROM events WHERE event_id = ?"
+
+        for ev in events:
+           if hasattr(ev, "prev_state"):
+                # Load previous state_content. 
+                # TODO: Should we be pulling this out above?
+                cursor = txn.execute(sql, (ev.prev_state,))
+                prevs = self.cursor_to_dict(cursor)
+                if prevs:
+                    prev = self._parse_event_from_row(prevs[0])
+                    ev.prev_content = prev.content
+
+        return events
 
 class Table(object):
     """ A base class used to store information about a particular table.