[omemo] Set devices inactive after 300 unacknowledged messages

This commit is contained in:
Philipp Hörist
2019-02-21 00:02:45 +01:00
parent d463caf034
commit 14a45be321
4 changed files with 39 additions and 5 deletions

View File

@@ -42,6 +42,7 @@ from omemo.backend.util import DEFAULT_PREKEY_AMOUNT
from omemo.backend.util import MIN_PREKEY_AMOUNT
from omemo.backend.util import SPK_CYCLE_TIME
from omemo.backend.util import SPK_ARCHIVE_TIME
from omemo.backend.util import UNACKNOWLEDGED_COUNT
log = logging.getLogger('gajim.plugin_system.omemo')
@@ -172,6 +173,12 @@ class OmemoState(DeviceManager):
whisper_messages = defaultdict(dict)
for jid_, device in devices_for_encryption:
count = self._storage.getUnacknowledgedCount(jid_, device)
if count >= UNACKNOWLEDGED_COUNT:
log.warning('Set device inactive %s because of %s '
'unacknowledged messages', device, count)
self.remove_device(jid_, device)
try:
whisper_messages[jid_][device] = self._get_whisper_message(
jid_, device, result.key)