Commit c3d5945a authored by Philipp Hörist's avatar Philipp Hörist

Presence: Remove auto auth if we unsubscribe

parent f43ea024
......@@ -59,7 +59,7 @@ def __init__(self, con):
self.automatically_added = []
# list of jid to auto-authorize
self.jids_for_auto_auth = []
self._jids_for_auto_auth = set()
def _presence_received(self, _con, stanza, properties):
if properties.from_muc:
......@@ -252,8 +252,9 @@ def _subscribe_received(self, _con, _stanza, properties):
properties.jid, is_transport,
auto_auth, properties.nickname)
if auto_auth or jid in self.jids_for_auto_auth:
if auto_auth or jid in self._jids_for_auto_auth:
self.send_presence(fjid, 'subscribed')
self._jids_for_auto_auth.discard(jid)
self._log.info('Auto respond with subscribed: %s', jid)
return
......@@ -304,7 +305,9 @@ def subscribed(self, jid):
def unsubscribed(self, jid):
if not app.account_is_connected(self._account):
return
self._log.info('Unsubscribed: %s', jid)
self._jids_for_auto_auth.discard(jid)
self.send_presence(jid, 'unsubscribed')
def unsubscribe(self, jid, remove_auth=True):
......@@ -318,6 +321,7 @@ def unsubscribe(self, jid, remove_auth=True):
app.config.del_per('contacts', j)
else:
self._log.info('Unsubscribe from %s', jid)
self._jids_for_auto_auth.discard(jid)
self._con.get_module('Roster').unsubscribe(jid)
self._con.get_module('Roster').set_item(jid)
......@@ -330,7 +334,7 @@ def subscribe(self, jid, msg=None, name='', groups=None, auto_auth=False):
self._log.info('Request Subscription to %s', jid)
if auto_auth:
self.jids_for_auto_auth.append(jid)
self.jids_for_auto_auth.add(jid)
infos = {'jid': jid}
if name:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment