diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-05-16 19:19:01 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2020-05-30 21:13:21 +0200 |
commit | 2d058ce137b2c9b8c06f7395e51826739b0f6db6 (patch) | |
tree | 61c5b003b53af35b5c56df6c9d5637f53c06b094 | |
parent | ba2b1c77fd32ae88fbccf2b238d4f2c15a8d0ccd (diff) | |
download | wee-slack-2d058ce137b2c9b8c06f7395e51826739b0f6db6.tar.gz |
Fetch thread when receiving a thread message and parent is not found
Fixes #619, fixes #754
-rw-r--r-- | wee_slack.py | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/wee_slack.py b/wee_slack.py index d05fc16..2e84cd9 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1988,6 +1988,9 @@ class SlackChannel(SlackChannelCommon): return w.buffer_get_integer(self.channel_buffer, "hidden") == 0 def get_history(self, slow_queue=False, full=False, no_log=False): + if self.identifier in self.pending_history_requests: + return + self.print_getting_history() self.pending_history_requests.add(self.identifier) @@ -2002,6 +2005,9 @@ class SlackChannel(SlackChannelCommon): self.history_needs_update = False def get_thread_history(self, thread_ts, slow_queue=False, no_log=False): + if thread_ts in self.pending_history_requests: + return + if config.thread_messages_in_channel: self.print_getting_history() thread_channel = self.thread_channels.get(thread_ts) @@ -3291,24 +3297,27 @@ def download_files(message_json, team): def subprocess_thread_message(message_json, eventrouter, team, channel, history_message): - parent_ts = message_json.get('thread_ts') - if parent_ts: - parent_message = channel.messages.get(SlackTS(parent_ts)) - if parent_message: - message = SlackThreadMessage(channel, parent_message.ts, message_json, team, channel) - if message.ts not in parent_message.submessages: - parent_message.submessages.append(message.ts) - parent_message.submessages.sort() - channel.store_message(message) - channel.change_message(parent_ts) - - if parent_message.thread_channel and parent_message.thread_channel.active: - if not history_message: - parent_message.thread_channel.prnt_message(message, history_message) + parent_ts = SlackTS(message_json['thread_ts']) + message = SlackThreadMessage(channel, parent_ts, message_json, team, channel) + + parent_message = message.parent_message + if parent_message and message.ts not in parent_message.submessages: + parent_message.submessages.append(message.ts) + parent_message.submessages.sort() + + channel.store_message(message) + if parent_message: + channel.change_message(parent_ts) + if parent_message.thread_channel and parent_message.thread_channel.active: + if not history_message: + parent_message.thread_channel.prnt_message(message, history_message) + else: parent_message.notify_thread(message) + else: + channel.get_thread_history(parent_ts) - return message + return message subprocess_thread_broadcast = subprocess_thread_message |