summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-05-04 15:19:12 +0100
committerErik Johnston <erik@matrix.org>2016-05-04 15:19:12 +0100
commit8e6a163f2762b3f62ae9b350c5050bc2318ec268 (patch)
treeaa7bc8a71f2ed9795bc65ce57d048a4ccc0be051 /synapse/storage
parentMove event_id to path (diff)
downloadsynapse-8e6a163f2762b3f62ae9b350c5050bc2318ec268.tar.xz
Add timestamp and auto incrementing ID
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/__init__.py1
-rw-r--r--synapse/storage/room.py6
-rw-r--r--synapse/storage/schema/delta/32/reports.sql2
3 files changed, 8 insertions, 1 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py
index 045ae6c03f..7122b0cbb1 100644
--- a/synapse/storage/__init__.py
+++ b/synapse/storage/__init__.py
@@ -114,6 +114,7 @@ class DataStore(RoomMemberStore, RoomStore,
         self._state_groups_id_gen = StreamIdGenerator(db_conn, "state_groups", "id")
         self._access_tokens_id_gen = IdGenerator(db_conn, "access_tokens", "id")
         self._refresh_tokens_id_gen = IdGenerator(db_conn, "refresh_tokens", "id")
+        self._event_reports_id_gen = IdGenerator(db_conn, "event_reports", "id")
         self._push_rule_id_gen = IdGenerator(db_conn, "push_rules", "id")
         self._push_rules_enable_id_gen = IdGenerator(db_conn, "push_rules_enable", "id")
         self._push_rules_stream_id_gen = ChainedIdGenerator(
diff --git a/synapse/storage/room.py b/synapse/storage/room.py
index ceced7d516..26933e593a 100644
--- a/synapse/storage/room.py
+++ b/synapse/storage/room.py
@@ -223,10 +223,14 @@ class RoomStore(SQLBaseStore):
 
         defer.returnValue((name, aliases))
 
-    def add_event_report(self, room_id, event_id, user_id, reason, content):
+    def add_event_report(self, room_id, event_id, user_id, reason, content,
+                         received_ts):
+        next_id = self._event_reports_id_gen.get_next()
         return self._simple_insert(
             table="event_reports",
             values={
+                "id": next_id,
+                "received_ts": received_ts,
                 "room_id": room_id,
                 "event_id": event_id,
                 "user_id": user_id,
diff --git a/synapse/storage/schema/delta/32/reports.sql b/synapse/storage/schema/delta/32/reports.sql
index 06bf0d9b5a..3f25027457 100644
--- a/synapse/storage/schema/delta/32/reports.sql
+++ b/synapse/storage/schema/delta/32/reports.sql
@@ -15,6 +15,8 @@
 
 
 CREATE TABLE event_reports(
+    id BIGINT NOT NULL,
+    received_ts BIGINT NOT NULL,
     room_id TEXT NOT NULL,
     event_id TEXT NOT NULL,
     user_id TEXT NOT NULL,