aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorAidan Epstein <aidan@jmad.org>2020-03-16 17:13:15 -0700
committerAidan Epstein <aidan@jmad.org>2020-03-21 08:38:39 -0700
commitb903c0d1d53eeb1d4626db0858042593b8c5d9cc (patch)
tree533339c0433d9c6d90edd295d0e485a791ba02d1 /wee_slack.py
parent5032d0c393e473cacb7681ee7cb7a2dd2e358594 (diff)
downloadwee-slack-b903c0d1d53eeb1d4626db0858042593b8c5d9cc.tar.gz
Update thread last_read mark.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 1994771..50cd1b5 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -114,7 +114,7 @@ SLACK_API_TRANSLATOR = {
"history": None,
"join": None,
"leave": None,
- "mark": None,
+ "mark": "subscriptions.thread.mark",
}
@@ -2266,9 +2266,16 @@ class SlackThreadChannel(SlackChannelCommon):
self.rename()
def mark_read(self, ts=None, update_remote=True, force=False):
- if self.channel_buffer:
- w.buffer_set(self.channel_buffer, "unread", "")
- w.buffer_set(self.channel_buffer, "hotlist", "-1")
+ if True or force: #TODO: Add check for new_messages here.
+ if self.channel_buffer:
+ w.buffer_set(self.channel_buffer, "unread", "")
+ w.buffer_set(self.channel_buffer, "hotlist", "-1")
+ if not ts:
+ ts = next(reversed(self.messages), SlackTS())
+ if update_remote:
+ s = SlackRequest(self.team, SLACK_API_TRANSLATOR[self.type]["mark"],
+ {"channel": self.identifier, "thread_ts": self.parent_message.ts, "ts": ts}, channel=self)
+ self.eventrouter.receive(s)
def buffer_prnt(self, nick, text, timestamp, tag_nick=None):
data = "{}\t{}".format(format_nick(nick, self.last_line_from), text)
@@ -3023,8 +3030,8 @@ def subprocess_thread_message(message_json, eventrouter, team, channel, history_
if parent_message.thread_channel and parent_message.thread_channel.active:
parent_message.thread_channel.buffer_prnt(message.sender, parent_message.thread_channel.render(message), message.ts, tag_nick=message.sender_plain)
- elif message.ts > channel.last_read and parent_message.subscribed: #TODO: What is the difference between this and message_replied, at least for alerting on threads?
- parent_message.notify_thread(action="subscribed", sender_id=message_json["user"]) #TODO: Update thread last read mark?
+ elif message.ts > channel.last_read and parent_message.subscribed:
+ parent_message.notify_thread(action="subscribed", sender_id=message_json["user"]) #TODO: Use thread last_read ts
elif message.ts > channel.last_read and message.has_mention():
parent_message.notify_thread(action="mention", sender_id=message_json["user"])