Merge branch 'master' of git@83.233.175.44:hermes
[hermes] / package / src / org / maemo / hermes / engine / facebook / service.py
index 9b9e6ec..fb18314 100644 (file)
@@ -85,18 +85,19 @@ class Service(org.maemo.hermes.engine.service.Service):
 
     # -----------------------------------------------------------------------
     def process_contact(self, contact):
+        matched_friend = None
         if self._friends_by_contact.has_key(contact):
-            return
+            matched_friend = self._friends_by_contact[contact]
         
-        matched_friend = None
         # we might get a hit if the friend has setup a URL with another service,
         # such as putting the id link to Facebook on the Twitter account's profile
-        for url in contact.get_urls():
-            if url in self._friends_by_url:
-                matched_friend = self._friends_by_url[url]
-                self._register_match(contact, matched_friend)
-                print contact.get_name(), " -> match by url -> ", matched_friend
-                return
+        if not matched_friend:
+            for url in contact.get_urls():
+                if url in self._friends_by_url:
+                    matched_friend = self._friends_by_url[url]
+                    self._register_match(contact, matched_friend)
+                    print contact.get_name(), " -> match by url -> ", matched_friend
+                    break
 
         if not matched_friend:
             for id in contact.get_identifiers():
@@ -104,15 +105,19 @@ class Service(org.maemo.hermes.engine.service.Service):
                     matched_friend = self._friends_by_name.pop(id)
                     self._register_match(contact, matched_friend)
                     print contact.get_name(), " -> match by name -> ", matched_friend
-                    return
+                    break
+                
+        return matched_friend
     
 
     # -----------------------------------------------------------------------
     def _register_match(self, contact, friend):
+        friend.set_contact(contact)
         self._friends_without_contact.discard(friend)
         self._friends_by_contact[contact] = friend
         self._contacts_by_friend[friend] = contact
 
+
     # -----------------------------------------------------------------------
     def _get_friends_data(self):
         """Returns a list of dicts, where each dict represents a friend/contact"""