aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorDaniel Nelson <daniel@wavesofdawn.com>2022-09-17 03:53:52 -0700
committerGitHub <noreply@github.com>2022-09-17 12:53:52 +0200
commit2db1df7ad9cde9471385912284bd8b7d3eb7758c (patch)
treecbd68de18a5cfd51fad948c417feff7b9570f471 /wee_slack.py
parent341f371e267c43b24bc15fb23eda683940dce133 (diff)
downloadwee-slack-2db1df7ad9cde9471385912284bd8b7d3eb7758c.tar.gz
Check closed IM channels for unread messages (#859)
On connection check closed IM channels for unread messages and if any are found open a buffer. This ensures that new direct messages are not missed.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 0ce5026..f58cfe2 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -98,6 +98,7 @@ SLACK_API_TRANSLATOR = {
"join": "conversations.open",
"leave": "conversations.close",
"mark": "conversations.mark",
+ "info": "conversations.info",
},
"mpim": {
"history": "conversations.history",
@@ -2266,6 +2267,14 @@ class SlackChannel(SlackChannelCommon):
is_open = self.is_open if hasattr(self, "is_open") else self.is_member
if is_open or self.unread_count_display:
self.create_buffer()
+ elif self.type == 'im':
+ # If it is an IM, we still might want to open it if there are unread messages.
+ info_method = self.team.slack_api_translator[self.type].get("info")
+ if info_method:
+ s = SlackRequest(
+ self.team, info_method, {"channel": self.identifier}, channel=self
+ )
+ self.eventrouter.receive(s)
def set_related_server(self, team):
self.team = team
@@ -3821,6 +3830,14 @@ 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"):