aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-09-19 19:05:35 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2023-09-22 16:55:53 +0200
commit99a232a7be043fbeca4e38bb752b103033495d18 (patch)
tree8ea3e1e016b07fe8c1beb99ae024450a585cdc90
parent7a7d55535a98a671a1ae6d09c4f9ebf648231320 (diff)
downloadwee-slack-99a232a7be043fbeca4e38bb752b103033495d18.tar.gz
Ignore some websocket messages for unknown channels
-rw-r--r--wee_slack.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 49221bb..5b34691 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -4143,6 +4143,9 @@ def process_pong(message_json, eventrouter, team, channel, metadata):
def process_message(
message_json, eventrouter, team, channel, metadata, history_message=False
):
+ if channel is None:
+ return
+
subtype = message_json.get("subtype")
if (
not history_message
@@ -4326,7 +4329,7 @@ def process_reply(message_json, eventrouter, team, channel, metadata):
def process_channel_marked(message_json, eventrouter, team, channel, metadata):
ts = message_json.get("ts")
- if ts:
+ if ts and channel is not None:
channel.mark_read(ts=ts, force=True, update_remote=False)
else:
dbg("tried to mark something weird {}".format(message_json))
@@ -4371,6 +4374,8 @@ def process_channel_created(message_json, eventrouter, team, channel, metadata):
def process_channel_rename(message_json, eventrouter, team, channel, metadata):
+ if channel is None:
+ return
channel.set_name(message_json["channel"]["name"])
@@ -4417,6 +4422,9 @@ def process_group_joined(message_json, eventrouter, team, channel, metadata):
def process_reaction_added(message_json, eventrouter, team, channel, metadata):
channel = team.channels.get(message_json["item"].get("channel"))
+ if channel is None:
+ return
+
if message_json["item"].get("type") == "message":
ts = SlackTS(message_json["item"]["ts"])
@@ -4430,6 +4438,9 @@ def process_reaction_added(message_json, eventrouter, team, channel, metadata):
def process_reaction_removed(message_json, eventrouter, team, channel, metadata):
channel = team.channels.get(message_json["item"].get("channel"))
+ if channel is None:
+ return
+
if message_json["item"].get("type") == "message":
ts = SlackTS(message_json["item"]["ts"])
@@ -4449,7 +4460,10 @@ def process_subteam_created(subteam_json, eventrouter, team, channel, metadata):
def process_subteam_updated(subteam_json, eventrouter, team, channel, metadata):
- current_subteam_info = team.subteams[subteam_json["subteam"]["id"]]
+ current_subteam_info = team.subteams.get(subteam_json["subteam"]["id"])
+ if current_subteam_info is None:
+ return
+
is_member = team.myidentifier in subteam_json["subteam"].get("users", [])
new_subteam_info = SlackSubteam(
team.identifier, is_member=is_member, **subteam_json["subteam"]