From 43886892a3bd3e6be4e9cce81b49ca29a982f799 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 6 Feb 2022 14:36:25 +0100 Subject: Handle conversations.info for all types This sets last_read on the channel, though we have no guarantee that we get the result from info before history, and if we get history first, the read messages will still be marked as unread. --- wee_slack.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'wee_slack.py') diff --git a/wee_slack.py b/wee_slack.py index da61ad7..77114b2 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -3741,16 +3741,17 @@ def handle_emojilist(emoji_json, eventrouter, team, channel, metadata): team.emoji_completions.extend(emoji_json["emoji"].keys()) -def handle_channelsinfo(channel_json, eventrouter, team, channel, metadata): - channel.set_unread_count_display( - channel_json["channel"].get("unread_count_display", 0) - ) - channel.set_members(channel_json["channel"]["members"]) - - -def handle_groupsinfo(group_json, eventrouter, team, channel, metadatas): - channel.set_unread_count_display(group_json["group"].get("unread_count_display", 0)) - channel.set_members(group_json["group"]["members"]) +def handle_conversationsinfo(channel_json, eventrouter, team, channel, metadata): + channel_info = channel_json["channel"] + if "unread_count_display" in channel_info: + unread_count = channel_info["unread_count_display"] + if channel_info["is_im"] and unread_count: + channel.check_should_open(True) + channel.set_unread_count_display(unread_count) + if "last_read" in channel_info: + channel.last_read = SlackTS(channel_info["last_read"]) + if "members" in channel_info: + channel.set_members(channel_info["members"]) def handle_conversationsopen( @@ -3856,14 +3857,6 @@ def handle_conversationsmembers(members_json, eventrouter, team, channel, metada ) -def handle_conversationsinfo(message_json, eventrouter, team, channel, metadata): - if message_json["channel"]["is_im"]: - unread = message_json["channel"]["unread_count_display"] - if unread: - channel.check_should_open(True) - channel.set_unread_count_display(unread) - - def handle_usersinfo(user_json, eventrouter, team, channel, metadata): user_info = user_json["user"] if not metadata.get("user"): -- cgit