summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-11-30 12:09:33 +0000
committerRichard van der Hoff <richard@matrix.org>2018-11-30 12:09:33 +0000
commit080025e5331d4d51943590800adb9c6c5257a047 (patch)
tree61b8f361b5ef59ba9866b6aa4d5869ebe4d4a1fc
parentInitial patch from Erik (diff)
downloadsynapse-080025e5331d4d51943590800adb9c6c5257a047.tar.xz
Fix buglet and remove thread_id stuff
-rw-r--r--synapse/rest/client/v1/room.py3
-rw-r--r--synapse/storage/events_worker.py9
2 files changed, 5 insertions, 7 deletions
diff --git a/synapse/rest/client/v1/room.py b/synapse/rest/client/v1/room.py
index 218dbb93ff..f296257b11 100644
--- a/synapse/rest/client/v1/room.py
+++ b/synapse/rest/client/v1/room.py
@@ -838,10 +838,9 @@ class TimestampLookupRestServlet(ClientV1RestServlet):
         yield self.auth.check_joined_room(room_id, requester.user.to_string())
 
         timestamp = parse_integer(request, "ts")
-        thread_id = parse_integer(request, "thread_id", 0)
 
         event_id = yield self.store.get_event_for_timestamp(
-            room_id, thread_id, timestamp,
+            room_id, timestamp,
         )
 
         defer.returnValue((200, {
diff --git a/synapse/storage/events_worker.py b/synapse/storage/events_worker.py
index e4d8562396..c5fee97ac9 100644
--- a/synapse/storage/events_worker.py
+++ b/synapse/storage/events_worker.py
@@ -527,33 +527,32 @@ class EventsWorkerStore(SQLBaseStore):
 
         return self.runInteraction("get_rejection_reasons", f)
 
-    def get_event_for_timestamp(self, room_id, thread_id, timestamp):
+    def get_event_for_timestamp(self, room_id, timestamp):
         sql_template = """
             SELECT event_id, origin_server_ts FROM events
             WHERE
                 origin_server_ts %s ?
                 AND room_id = ?
-                AND thread_id = ?
             ORDER BY origin_server_ts
             LIMIT 1;
         """
 
         def f(txn):
-            txn.execute(sql_template % ("<=",), (timestamp, room_id, thread_id))
+            txn.execute(sql_template % ("<=",), (timestamp, room_id))
             row = txn.fetchone()
             if row:
                 event_id_before, ts_before = row
             else:
                 event_id_before, ts_before = None, None
 
-            txn.execute(sql_template % (">=",), (timestamp, room_id, thread_id))
+            txn.execute(sql_template % (">=",), (timestamp, room_id))
             row = txn.fetchone()
             if row:
                 event_id_after, ts_after = row
             else:
                 event_id_after, ts_after = None, None
 
-            if event_id_before and event_id_before:
+            if event_id_before and event_id_after:
                 # Return the closest one
                 if (timestamp - ts_before) < (ts_after - timestamp):
                     return event_id_before