Ignore undecryptable messages when expiring.

This commit is contained in:
tecnovert 2022-10-12 20:48:26 +02:00
parent 5f0e708812
commit 3ed6781c9f
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93

View file

@ -3560,12 +3560,17 @@ class BasicSwap(BaseApp):
num_messages = 0 num_messages = 0
num_removed = 0 num_removed = 0
for msg in ro['messages']: for msg in ro['messages']:
num_messages += 1 try:
expire_at = msg['sent'] + msg['ttl'] num_messages += 1
if expire_at < now: expire_at = msg['sent'] + msg['ttl']
options = {'encoding': 'none', 'delete': True} if expire_at < now:
del_msg = ci_part.json_request(rpc_conn, 'smsg', [msg['msgid'], options]) options = {'encoding': 'none', 'delete': True}
num_removed += 1 del_msg = ci_part.json_request(rpc_conn, 'smsg', [msg['msgid'], options])
num_removed += 1
except Exception as e:
if self.debug:
self.log.error(traceback.format_exc())
continue
if num_messages + num_removed > 0: if num_messages + num_removed > 0:
self.log.info('Expired {} / {} messages.'.format(num_removed, num_messages)) self.log.info('Expired {} / {} messages.'.format(num_removed, num_messages))