aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-05-04 22:41:31 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2020-05-30 21:13:21 +0200
commit91b69403223c531d5dbfe2e445092d9e13229775 (patch)
treeea4268fc53d0b2263aa403ba3d57dff4ff63bd52
parent979db32b477a192cc150b2696167aa575fd99ff5 (diff)
downloadwee-slack-91b69403223c531d5dbfe2e445092d9e13229775.tar.gz
Move store_message back into subprocess functions
In subprocess_thread_message we need to store the message before calling notify_thread, so storing it after the function returned didn't work. This is because when auto_open_threads is on and you get a new message, it will open the thread and print the messages immediately, which will fail because the message ts has been added to submessages, but the message has not been stored yet.
-rw-r--r--wee_slack.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 1b20e1a..bda673e 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -3120,12 +3120,11 @@ def process_message(message_json, eventrouter, team, channel, metadata, history_
message = subtype_functions[subtype](message_json, eventrouter, team, channel, history_message)
else:
message = SlackMessage(subtype or "normal", message_json, team, channel)
+ channel.store_message(message)
channel.unread_count_display += 1
- if message:
- channel.store_message(message)
- if not history_message:
- channel.prnt_message(message, history_message)
+ if message and not history_message:
+ channel.prnt_message(message, history_message)
if not history_message:
download_files(message_json, team)
@@ -3175,6 +3174,7 @@ def subprocess_thread_message(message_json, eventrouter, team, channel, history_
parent_message = channel.messages.get(SlackTS(parent_ts))
if parent_message:
message = SlackThreadMessage(parent_message, message_json, team, channel)
+ channel.store_message(message)
if message.ts not in parent_message.submessages:
parent_message.submessages.append(message.ts)
parent_message.submessages.sort()
@@ -3197,18 +3197,21 @@ subprocess_thread_broadcast = subprocess_thread_message
def subprocess_channel_join(message_json, eventrouter, team, channel, history_message):
message = SlackMessage("join", message_json, team, channel)
+ channel.store_message(message)
channel.user_joined(message_json["user"])
return message
def subprocess_channel_leave(message_json, eventrouter, team, channel, history_message):
message = SlackMessage("leave", message_json, team, channel)
+ channel.store_message(message)
channel.user_left(message_json["user"])
return message
def subprocess_channel_topic(message_json, eventrouter, team, channel, history_message):
message = SlackMessage("topic", message_json, team, channel)
+ channel.store_message(message)
channel.set_topic(message_json["topic"])
return message