From e1d1ed78763560f37da243294712381235179004 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sat, 18 Aug 2018 09:39:30 +0200 Subject: Clear messages before processing history If a message arrived after history was requested, but before the response arrived, it would be lost. It would be printed after the "getting channel history" text, and then handle_history would clear that, and it would not be printed again since the message ts already was processed. By clearing the messages dict, the message will get processed and printed again. So we should never clear the buffer without also clearing the messages, to prevent such problems. --- wee_slack.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'wee_slack.py') diff --git a/wee_slack.py b/wee_slack.py index e8c42e9..4eec7fb 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2373,14 +2373,9 @@ def handle_history(message_json, eventrouter, **kwargs): request_metadata = pickle.loads(message_json["wee_slack_request_metadata"]) kwargs['team'] = eventrouter.teams[request_metadata.team_hash] kwargs['channel'] = kwargs['team'].channels[request_metadata.channel_identifier] - try: - clear = request_metadata.clear - except: - clear = False - dbg(clear) - kwargs['output_type'] = "backlog" - if clear: - w.buffer_clear(kwargs['channel'].channel_buffer) + if getattr(request_metadata, 'clear', False): + kwargs['channel'].clear_messages() + kwargs['channel'].got_history = True for message in reversed(message_json["messages"]): process_message(message, eventrouter, **kwargs) -- cgit