Remove old message duplicate code
- Calculating so many hashes for each Message is quite expensive - It hides our own implementation bugs, like when we retrieve history from a MUC with wrong timestamps, or on rejoin. We never know about it because the Messages are dropped. - It should not be necessary anymore. The original problem was a bug in nbxmpp which triggered mass resending of old messages.
This commit is contained in:
parent
07055ccaad
commit
46926e71d1
|
@ -725,8 +725,6 @@ class ConnectionHandlersBase:
|
|||
# IDs of sent messages (https://trac.gajim.org/ticket/8222)
|
||||
self.sent_message_ids = []
|
||||
|
||||
self.received_message_hashes = []
|
||||
|
||||
# We decrypt GPG messages one after the other. Keep queue in mem
|
||||
self.gpg_messages_to_decrypt = []
|
||||
|
||||
|
@ -2048,8 +2046,6 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream):
|
|||
app.nec.push_incoming_event(SignedInEvent(None, conn=self))
|
||||
self.send_awaiting_pep()
|
||||
self.continue_connect_info = None
|
||||
# hashes of already received messages
|
||||
self.received_message_hashes = []
|
||||
|
||||
def _SearchCB(self, con, iq_obj):
|
||||
log.debug('SearchCB')
|
||||
|
|
|
@ -1472,22 +1472,6 @@ class DecryptedMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
|||
if replace:
|
||||
self.correct_id = replace.getAttr('id')
|
||||
|
||||
# ignore message duplicates
|
||||
if self.msgtxt and self.id_ and self.jid:
|
||||
self.msghash = hashlib.sha256(("%s|%s|%s" % (
|
||||
hashlib.sha256(self.msgtxt.encode('utf-8')).hexdigest(),
|
||||
hashlib.sha256(self.id_.encode('utf-8')).hexdigest(),
|
||||
hashlib.sha256(self.jid.encode('utf-8')).hexdigest())).encode(
|
||||
'utf-8')).digest()
|
||||
if self.msghash in self.conn.received_message_hashes:
|
||||
log.info("Ignoring duplicated message from '%s' with id '%s'" % (self.jid, self.id_))
|
||||
return False
|
||||
else:
|
||||
log.debug("subhashes: msgtxt, id_, jid = ('%s', '%s', '%s')" % (hashlib.sha256(self.msgtxt.encode('utf-8')).hexdigest(), hashlib.sha256(self.id_.encode('utf-8')).hexdigest(), hashlib.sha256(self.jid.encode('utf-8')).hexdigest()))
|
||||
self.conn.received_message_hashes.append(self.msghash)
|
||||
# only record the last 20000 hashes (should be about 1MB [32 bytes per hash]
|
||||
# and about 24 hours if you receive a message every 5 seconds)
|
||||
self.conn.received_message_hashes = self.conn.received_message_hashes[-20000:]
|
||||
return True
|
||||
|
||||
class ChatstateReceivedEvent(nec.NetworkIncomingEvent):
|
||||
|
|
Loading…
Reference in New Issue