diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2022-02-06 14:36:25 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2022-09-18 16:36:55 +0200 |
commit | 43886892a3bd3e6be4e9cce81b49ca29a982f799 (patch) | |
tree | 1eca9dc05abce7e5099f22cdf7d7a610c223d4ef | |
parent | 55cc97e60f84b3a9ac4d4397f4f641d1a104f718 (diff) | |
download | wee-slack-43886892a3bd3e6be4e9cce81b49ca29a982f799.tar.gz |
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.
-rw-r--r-- | wee_slack.py | 29 |
1 files changed, 11 insertions, 18 deletions
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"): |