aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2018-08-20 20:10:03 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2018-08-20 20:10:03 +0200
commit01b5219b6f9ad17cd8fd5ca6a6a5f26eb8ee8cc2 (patch)
tree591f454963d59ba82c5d40fdf6d42f648557bfc4 /wee_slack.py
parent2bd6c07e10b4a2b78638e19a9bfa71ecc00c58bc (diff)
downloadwee-slack-01b5219b6f9ad17cd8fd5ca6a6a5f26eb8ee8cc2.tar.gz
Handle missing unread_count_display fields
I have experienced unread_count_display missing from channels.info for some channels. It seems consistent for those particular channels, but I'm not sure what's different about them, or why it's missing from them. I haven't seen it missing from groups.info or conversations.open, but I figured it was best to set it the same way in the three methods.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 4db5f94..ec7fa9a 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2336,7 +2336,7 @@ def handle_channelsinfo(channel_json, eventrouter, **kwargs):
request_metadata = pickle.loads(channel_json["wee_slack_request_metadata"])
team = eventrouter.teams[request_metadata.team_hash]
channel = team.channels[request_metadata.channel_identifier]
- channel.set_unread_count_display(channel_json['channel']['unread_count_display'])
+ channel.set_unread_count_display(channel_json['channel'].get('unread_count_display', 0))
channel.set_members(channel_json['channel']['members'])
@@ -2344,19 +2344,16 @@ def handle_groupsinfo(group_json, eventrouter, **kwargs):
request_metadata = pickle.loads(group_json["wee_slack_request_metadata"])
team = eventrouter.teams[request_metadata.team_hash]
group = team.channels[request_metadata.channel_identifier]
- unread_count_display = group_json['group']['unread_count_display']
- group_id = group_json['group']['id']
- group.set_unread_count_display(unread_count_display)
+ group.set_unread_count_display(group_json['group'].get('unread_count_display', 0))
def handle_conversationsopen(conversation_json, eventrouter, object_name='channel', **kwargs):
request_metadata = pickle.loads(conversation_json["wee_slack_request_metadata"])
# Set unread count if the channel isn't new (channel_identifier exists)
if hasattr(request_metadata, 'channel_identifier'):
- channel_id = request_metadata.channel_identifier
team = eventrouter.teams[request_metadata.team_hash]
- conversation = team.channels[channel_id]
- unread_count_display = conversation_json[object_name]['unread_count_display']
+ conversation = team.channels[request_metadata.channel_identifier]
+ unread_count_display = conversation_json[object_name].get('unread_count_display', 0)
conversation.set_unread_count_display(unread_count_display)