Set hashed_messages[message.hash] if not present in hash_message
A channel and a thread channel in that channel has the same message
instances, but different hashed_messages dictionaries. Therefore,
message.hash may be set, without it being present in hashed_messages.
Insert it into hashed_messages in hash_message if that is the case.
@@ -1634,8 +1634,9 @@ class SlackChannelCommon(object):
def calc_hash(ts):
return sha1_hex(str(ts))
- if ts in self.messages and not self.messages[ts].hash:
- message = self.messages[ts]
+ message = self.messages.get(ts)
+ if message is not None:
+ if not message.hash:
tshash = calc_hash(message.ts)
hl = 3
@@ -1661,11 +1662,13 @@ class SlackChannelCommon(object):
if col_msg.thread_channel:
col_msg.thread_channel.rename()
- self.hashed_messages[shorthash] = message.ts
message.hash = shorthash
- return shorthash
- elif ts in self.messages:
- return self.messages[ts].hash
+ self.hashed_messages[message.hash] = message.ts
+
+ elif message.hash not in self.hashed_messages:
+ self.hashed_messages[message.hash] = message.ts
+
+ return message.hash
def mark_read(self, ts=None, update_remote=True, force=False, post_data={}):
if self.new_messages or force:
