we now detect loop when server isn't RFC complient and handle badly subscription acknoledgment. Fixes #1864
This commit is contained in:
parent
134483f936
commit
394381a78a
|
@ -1055,6 +1055,9 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
|
|||
# keep the jids we auto added (transports contacts) to not send the
|
||||
# SUBSCRIBED event to gui
|
||||
self.automatically_added = []
|
||||
# keep the latest subscribed event for each jid to prevent loop when we
|
||||
# acknoledge presences
|
||||
self.subscribed_events = {}
|
||||
try:
|
||||
idle.init()
|
||||
except:
|
||||
|
@ -1527,6 +1530,19 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
|
|||
elif ptype == 'subscribed':
|
||||
if jid_stripped in self.automatically_added:
|
||||
self.automatically_added.remove(jid_stripped)
|
||||
else:
|
||||
# detect a subscription loop
|
||||
if not self.subscribed_events.has_key(jid_stripped):
|
||||
self.subscribed_events[jid_stripped] = []
|
||||
self.subscribed_events[jid_stripped].append(time.time())
|
||||
block = False
|
||||
if len(self.subscribed_events[jid_stripped]) > 5:
|
||||
if time.time() - self.subscribed_events[jid_stripped][0] < 5:
|
||||
block = True
|
||||
self.subscribed_events[jid_stripped] = self.subscribed_events[jid_stripped][1:]
|
||||
if block:
|
||||
gajim.config.set_per('account', self.name,
|
||||
'dont_ack_subscription', True)
|
||||
else:
|
||||
self.dispatch('SUBSCRIBED', (jid_stripped, resource))
|
||||
# BE CAREFUL: no con.updateRosterItem() in a callback
|
||||
|
|
Loading…
Reference in New Issue