aboutsummaryrefslogtreecommitdiffstats
path: root/slack/slack_thread.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-10-02 00:19:45 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commit12ce8befda90d79ff3c1533770e38f865728482f (patch)
tree16bd450c00441b515519da69b88b9a40df8550d5 /slack/slack_thread.py
parent91312364d70efaa3a0c6d4e8a15965383df5fcf7 (diff)
downloadwee-slack-12ce8befda90d79ff3c1533770e38f865728482f.tar.gz
Mark as read when switching away from buffer
Diffstat (limited to 'slack/slack_thread.py')
-rw-r--r--slack/slack_thread.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/slack/slack_thread.py b/slack/slack_thread.py
index 44a6751..24bdc66 100644
--- a/slack/slack_thread.py
+++ b/slack/slack_thread.py
@@ -91,3 +91,18 @@ class SlackThread(SlackBuffer):
await self.print_history()
self.history_pending = False
+
+ async def mark_read(self):
+ # subscriptions.thread.mark is only available for session tokens
+ if self.workspace.token_type != "session":
+ return
+
+ # last_read can only be set if it exists (which is on threads you're subscribed to)
+ if self.last_read == SlackTs("0.0"):
+ return
+
+ last_read_line_ts = self.last_read_line_ts()
+ if last_read_line_ts and last_read_line_ts != self.last_read:
+ await self._api.subscriptions_thread_mark(
+ self.parent.conversation, self.parent.ts, last_read_line_ts
+ )