diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-10-15 18:42:44 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:54 +0100 |
commit | e66ff9e2e493b46457cc3d2794fcfaec457474d0 (patch) | |
tree | 5ceb5faa9501398702f90501812a317ec1232d3b /slack | |
parent | a395ba53ac7b6f6376ea8500902a8405d034874e (diff) | |
download | wee-slack-e66ff9e2e493b46457cc3d2794fcfaec457474d0.tar.gz |
Don't crash when message for hash is missing
We can have a hash for a message we don't have if e.g. a broadcast reply
is sent, and the parent is older than the history we have fetched.
Diffstat (limited to 'slack')
-rw-r--r-- | slack/slack_conversation.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py index e71d8ad..f9c36d5 100644 --- a/slack/slack_conversation.py +++ b/slack/slack_conversation.py @@ -95,12 +95,13 @@ class SlackConversationMessageHashes(Dict[SlackTs, str]): self._setitem(ts_with_same_hash, other_short_hash) self._inverse_map[other_short_hash] = ts_with_same_hash - other_message = self._conversation.messages[ts_with_same_hash] - run_async(self._conversation.rerender_message(other_message)) - if other_message.thread_buffer is not None: - run_async(other_message.thread_buffer.update_buffer_props()) - for reply in other_message.replies.values(): - run_async(self._conversation.rerender_message(reply)) + other_message = self._conversation.messages.get(ts_with_same_hash) + if other_message: + run_async(self._conversation.rerender_message(other_message)) + if other_message.thread_buffer is not None: + run_async(other_message.thread_buffer.update_buffer_props()) + for reply in other_message.replies.values(): + run_async(self._conversation.rerender_message(reply)) self._setitem(key, short_hash) self._inverse_map[short_hash] = key |