aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-05-14 00:44:48 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2020-05-30 21:13:21 +0200
commit4210fa2e438644bfde1b0f2637076e473d46a9fe (patch)
treecb8dca5aa2bbd620d3af87fb8d125526fd35292d /wee_slack.py
parentb79099c6f76bc4f75dab1616a58a45dc6780cbf4 (diff)
downloadwee-slack-4210fa2e438644bfde1b0f2637076e473d46a9fe.tar.gz
Support old messages in thread (un)subscribe
Old messages, as in parent messages that's older than the history we fetch.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 4cc18f5..3b86750 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -3462,17 +3462,23 @@ def process_emoji_changed(message_json, eventrouter, team, channel, metadata):
def process_thread_subscribed(message_json, eventrouter, team, channel, metadata):
dbg("THREAD SUBSCRIBED {}".format(message_json))
channel = team.channels[message_json["subscription"]["channel"]]
- parent_ts = message_json["subscription"]["thread_ts"]
- channel.messages.get(SlackTS(parent_ts)).subscribed = True
- channel.change_message(parent_ts)
+ parent_ts = SlackTS(message_json["subscription"]["thread_ts"])
+ parent_message = channel.messages.get(parent_ts)
+ if parent_message:
+ parent_message.subscribed = True
+ channel.change_message(parent_ts)
+ else:
+ channel.get_thread_history(parent_ts)
def process_thread_unsubscribed(message_json, eventrouter, team, channel, metadata):
dbg("THREAD UNSUBSCRIBED {}".format(message_json))
channel = team.channels[message_json["subscription"]["channel"]]
- parent_ts = message_json["subscription"]["thread_ts"]
- channel.messages.get(SlackTS(parent_ts)).subscribed = False
- channel.change_message(parent_ts)
+ parent_ts = SlackTS(message_json["subscription"]["thread_ts"])
+ parent_message = channel.messages.get(parent_ts)
+ if parent_message:
+ parent_message.subscribed = False
+ channel.change_message(parent_ts)
###### New module/global methods