From b86c5cc4903e737bb95aafa240ca3706d090c453 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 31 Jul 2019 16:04:26 -0700 Subject: [PATCH] Revert "events: Check last_event_id for validity." This isn't correct without a proper migration for existing queues, which may not be implementable. This reverts commit e00d4be6d57ca8282a668f9aec2c835d367c6f69. --- zerver/tests/test_tornado.py | 2 +- zerver/tornado/event_queue.py | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/zerver/tests/test_tornado.py b/zerver/tests/test_tornado.py index 8a0e88fcbb..e9bdcb6125 100644 --- a/zerver/tests/test_tornado.py +++ b/zerver/tests/test_tornado.py @@ -117,7 +117,7 @@ class EventsTestCase(TornadoWebTestCase): event_queue_id = self.create_queue() data = { 'queue_id': event_queue_id, - 'last_event_id': -1, + 'last_event_id': 0, } path = '/json/events?{}'.format(urllib.parse.urlencode(data)) diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.py index 261977c179..ab44e178ae 100644 --- a/zerver/tornado/event_queue.py +++ b/zerver/tornado/event_queue.py @@ -240,7 +240,6 @@ class EventQueue: def __init__(self, id: str) -> None: self.queue = deque() # type: ignore # Should be Deque[Dict[str, Any]], but Deque isn't available in Python 3.4 self.next_event_id = 0 # type: int - self.newest_pruned_id = -1 # type: int self.id = id # type: str self.virtual_events = {} # type: Dict[str, Dict[str, Any]] @@ -296,7 +295,6 @@ class EventQueue: # See the comment on pop; that applies here as well def prune(self, through_id: int) -> None: while len(self.queue) != 0 and self.queue[0]['id'] <= through_id: - self.newest_pruned_id = self.queue[0]['id'] self.pop() def contents(self) -> List[Dict[str, Any]]: @@ -524,11 +522,7 @@ def fetch_events(query: Mapping[str, Any]) -> Dict[str, Any]: raise BadEventQueueIdError(queue_id) if user_profile_id != client.user_profile_id: raise JsonableError(_("You are not authorized to get events from this queue")) - if last_event_id < client.event_queue.newest_pruned_id: - raise JsonableError(_("An event newer than %s has already been pruned!") % (last_event_id,)) client.event_queue.prune(last_event_id) - if last_event_id != client.event_queue.newest_pruned_id: - raise JsonableError(_("Event %s was not in this queue") % (last_event_id,)) was_connected = client.finish_current_handler() if not client.event_queue.empty() or dont_block: