summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-12-03 10:15:39 +0000
committerRichard van der Hoff <richard@matrix.org>2018-12-03 10:15:39 +0000
commitc4074e4ab67e53705029657147e847ee08a429b5 (patch)
tree6f69b034a56669cb0512e76c87b71789d0b8b3db
parentMerge branch 'rav/timestamp_patch' into matrix-org-hotfixes (diff)
downloadsynapse-c4074e4ab67e53705029657147e847ee08a429b5.tar.xz
Revert "Merge branch 'rav/timestamp_patch' into matrix-org-hotfixes"
This reverts commit 7960e814e5386b32821ef51915e609091e6e1569, reversing
changes made to 3dd704ee9af836b9b3e50daf1017a3d65c9ebaec.

We no longer need this; please redo it as a proper MSC & synapse PR if you want
to keep it...
-rw-r--r--synapse/rest/client/v1/room.py24
-rw-r--r--synapse/storage/events_worker.py39
2 files changed, 0 insertions, 63 deletions
diff --git a/synapse/rest/client/v1/room.py b/synapse/rest/client/v1/room.py
index f296257b11..fcfe7857f6 100644
--- a/synapse/rest/client/v1/room.py
+++ b/synapse/rest/client/v1/room.py
@@ -825,29 +825,6 @@ class JoinedRoomsRestServlet(ClientV1RestServlet):
         defer.returnValue((200, {"joined_rooms": list(room_ids)}))
 
 
-class TimestampLookupRestServlet(ClientV1RestServlet):
-    PATTERNS = client_path_patterns("/rooms/(?P<room_id>[^/]*)/timestamp_to_event$")
-
-    def __init__(self, hs):
-        super(TimestampLookupRestServlet, self).__init__(hs)
-        self.store = hs.get_datastore()
-
-    @defer.inlineCallbacks
-    def on_GET(self, request, room_id):
-        requester = yield self.auth.get_user_by_req(request)
-        yield self.auth.check_joined_room(room_id, requester.user.to_string())
-
-        timestamp = parse_integer(request, "ts")
-
-        event_id = yield self.store.get_event_for_timestamp(
-            room_id, timestamp,
-        )
-
-        defer.returnValue((200, {
-            "event_id": event_id,
-        }))
-
-
 def register_txn_path(servlet, regex_string, http_server, with_get=False):
     """Registers a transaction-based path.
 
@@ -897,7 +874,6 @@ def register_servlets(hs, http_server):
     JoinedRoomsRestServlet(hs).register(http_server)
     RoomEventServlet(hs).register(http_server)
     RoomEventContextServlet(hs).register(http_server)
-    TimestampLookupRestServlet(hs).register(http_server)
 
 
 def register_deprecated_servlets(hs, http_server):
diff --git a/synapse/storage/events_worker.py b/synapse/storage/events_worker.py
index c5fee97ac9..a8326f5296 100644
--- a/synapse/storage/events_worker.py
+++ b/synapse/storage/events_worker.py
@@ -526,42 +526,3 @@ class EventsWorkerStore(SQLBaseStore):
             return res
 
         return self.runInteraction("get_rejection_reasons", f)
-
-    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 = ?
-            ORDER BY origin_server_ts
-            LIMIT 1;
-        """
-
-        def f(txn):
-            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))
-            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_after:
-                # Return the closest one
-                if (timestamp - ts_before) < (ts_after - timestamp):
-                    return event_id_before
-                else:
-                    return event_id_after
-
-            if event_id_before:
-                return event_id_before
-
-            return event_id_after
-
-        return self.runInteraction("get_event_for_timestamp", f)