aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-05-14 01:15:12 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2020-05-30 21:13:21 +0200
commit8272a464702d8e35c495099294547b7018c284c7 (patch)
treec35a29e8c43080136801b6eab0b6157e51425e88 /wee_slack.py
parent63d39dc5f71dcbfd46c120d285a91fcf8cc4ef0d (diff)
downloadwee-slack-8272a464702d8e35c495099294547b7018c284c7.tar.gz
Set last_read to SlackTS(0) when missing
When last_read is missing, we should assume no messages are read instead of all up until the channel/message is created. The only time I know this happens is for messages that are not yet thread parents. This probably doesn't matter in practice though. For new thread parents the messages that make it a thread parent will arrive after we create the message, so they would have newer ts than the one we set for last_read. Still, I think it makes more sense to set it to 0.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py
index a34d057..46f20a6 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1744,7 +1744,7 @@ class SlackChannel(SlackChannelCommon):
self.set_name(kwargs["name"])
self.slack_purpose = kwargs.get("purpose", {"value": ""})
self.topic = kwargs.get("topic", {"value": ""})
- self.last_read = SlackTS(kwargs.get("last_read", SlackTS()))
+ self.last_read = SlackTS(kwargs.get("last_read", 0))
self.channel_buffer = None
self.got_history = False
self.history_needs_update = False
@@ -2616,7 +2616,7 @@ class SlackMessage(object):
self.hash = None
self.ts = SlackTS(message_json['ts'])
self.subscribed = message_json.get("subscribed", False)
- self.last_read = SlackTS(message_json.get("last_read", SlackTS()))
+ self.last_read = SlackTS(message_json.get("last_read", 0))
def __hash__(self):
return hash(self.ts)
@@ -2794,7 +2794,10 @@ class Hdata(object):
class SlackTS(object):
def __init__(self, ts=None):
- if ts:
+ if isinstance(ts, int):
+ self.major = ts
+ self.minor = 0
+ elif ts is not None:
self.major, self.minor = [int(x) for x in ts.split('.', 1)]
else:
self.major = int(time.time())