From e66ff9e2e493b46457cc3d2794fcfaec457474d0 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 15 Oct 2023 18:42:44 +0200 Subject: 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. --- slack/slack_conversation.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'slack') 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 -- cgit