remove contact from server list if it's useless (sub=ask=name=groups=None). Fixes #1821
This commit is contained in:
parent
e51ed3f220
commit
cb242e2bbd
|
@ -1564,18 +1564,21 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
|
||||||
def _on_roster_set(self, roster):
|
def _on_roster_set(self, roster):
|
||||||
raw_roster = roster.getRaw()
|
raw_roster = roster.getRaw()
|
||||||
roster = {}
|
roster = {}
|
||||||
|
our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name))
|
||||||
for jid in raw_roster:
|
for jid in raw_roster:
|
||||||
try:
|
try:
|
||||||
j = helpers.parse_jid(jid)
|
j = helpers.parse_jid(jid)
|
||||||
except:
|
except:
|
||||||
print >> sys.stderr, _('JID %s is not RFC compliant. It will not be added to your roster. Use roster management tools such as http://jru.jabberstudio.org/ to remove it') % jid
|
print >> sys.stderr, _('JID %s is not RFC compliant. It will not be added to your roster. Use roster management tools such as http://jru.jabberstudio.org/ to remove it') % jid
|
||||||
else:
|
else:
|
||||||
roster[j] = raw_roster[jid]
|
infos = raw_roster[jid]
|
||||||
|
if jid != our_jid and (not infos['subscription'] or infos['subscription'] == \
|
||||||
# Remove or jid
|
'none') and (not infos['ask'] or infos['ask'] == 'none') and not infos['name'] \
|
||||||
our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name))
|
and not infos['groups']:
|
||||||
if roster.has_key(our_jid):
|
# remove this useless item, it won't be shown in roster anyway
|
||||||
del roster[our_jid]
|
self.connection.getRoster().delItem(jid)
|
||||||
|
elif jid != our_jid: # don't add our jid
|
||||||
|
roster[j] = raw_roster[jid]
|
||||||
|
|
||||||
self.dispatch('ROSTER', roster)
|
self.dispatch('ROSTER', roster)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue