aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2018-08-18 09:39:30 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2018-08-18 09:39:40 +0200
commite1d1ed78763560f37da243294712381235179004 (patch)
treeb6b6a4274200ec566e95b7415c012426c96804fb
parent0eaf9ed4057f4adbfeb57289f7cc12774027a9aa (diff)
downloadwee-slack-e1d1ed78763560f37da243294712381235179004.tar.gz
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.
-rw-r--r--wee_slack.py11
1 files changed, 3 insertions, 8 deletions
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)