aboutsummaryrefslogtreecommitdiffstats
path: root/slack/slack_message.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-10-01 21:31:08 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commit6cf20324f97fa49bade19ecf1f46e2900c2eda08 (patch)
treea4322caa518f577d8d7154cf4a45509b726ecfb3 /slack/slack_message.py
parent2733d6a0faf3ea9150ee8e16950ca3d54a6361e6 (diff)
downloadwee-slack-6cf20324f97fa49bade19ecf1f46e2900c2eda08.tar.gz
Correctly tag unread messages from history
Now notify tags are set based on last_read so both read and unread messages gets the correct tags irregardless if they come from history or websocket.
Diffstat (limited to 'slack/slack_message.py')
-rw-r--r--slack/slack_message.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/slack/slack_message.py b/slack/slack_message.py
index 36faa5f..968c1f7 100644
--- a/slack/slack_message.py
+++ b/slack/slack_message.py
@@ -195,6 +195,13 @@ class SlackMessage:
return self.conversation.messages.get(self.thread_ts)
@property
+ def last_read(self) -> SlackTs:
+ if "last_read" in self._message_json:
+ return SlackTs(self._message_json["last_read"])
+ else:
+ return SlackTs("0.0")
+
+ @property
def is_bot_message(self) -> bool:
return (
"subtype" in self._message_json
@@ -290,7 +297,7 @@ class SlackMessage:
return False
- async def tags(self, backlog: bool = False) -> str:
+ async def tags(self, backlog: bool) -> str:
nick = await self.nick(colorize=False, only_nick=True)
tags = [f"slack_ts_{self.ts}", f"nick_{nick}"]