From 29071dda001e424d4b4dd20a7fc0cae2d4b0c0f4 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sun, 8 Jan 2006 00:39:05 +0000 Subject: [PATCH] fix logic in contacts.add_contact() function --- src/common/contacts.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/contacts.py b/src/common/contacts.py index 5fac855bc..29c2869ff 100644 --- a/src/common/contacts.py +++ b/src/common/contacts.py @@ -118,12 +118,16 @@ class Contacts: if not self._contacts[account].has_key(contact.jid): self._contacts[account][contact.jid] = [contact] return + contacts = self._contacts[account][contact.jid] + # We had only one that was offline, remove it + if len(contacts) == 1 and contacts[0].show == 'offline': + self.remove_contact(account, contacts[0]) # If same JID with same resource already exists, use the new one - for c in self._contacts[account][contact.jid]: + for c in contacts: if c.resource == contact.resource: self.remove_contact(account, c) break - self._contacts[account][contact.jid].append(contact) + contacts.append(contact) def remove_contact(self, account, contact): if not self._contacts.has_key(account):