]> git.mxchange.org Git - friendica-addons.git/commitdiff
fbsync: prevent falsely added copntacts
authorMichael Vogel <icarus@dabo.de>
Wed, 25 Jun 2014 07:11:09 +0000 (09:11 +0200)
committerMichael Vogel <icarus@dabo.de>
Wed, 25 Jun 2014 07:11:09 +0000 (09:11 +0200)
fbsync/fbsync.php

index 14de4df25a0e1390d11acf263aff830a216a7a92..bcd4e5a8d51bd70cc0c44011aef4f1d90364a120 100644 (file)
@@ -278,10 +278,19 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
        }
 
        if ($contact_id <= 0) {
-               // To-Do:
-               // $contacts[$post->source_id] seems to be wrong by repeated posts
-               // must be changed in future
-               $contact_id = fbsync_fetch_contact($uid, $contacts[$post->source_id], $create_user);
+               if ($post->actor_id != $post->source_id) {
+                       // Testing if we know the source or the actor
+                       $contact_id = fbsync_fetch_contact($uid, $contacts[$post->source_id], false);
+
+                       if (($contact_id == 0) and array_key_exists($post->actor_id, $contacts))
+                               $contact_id = fbsync_fetch_contact($uid, $contacts[$post->actor_id], false);
+
+                       // If we don't know anyone, we guess we should know the source. Could be the wrong decision
+                       if ($contact_id == 0)
+                               $contact_id = fbsync_fetch_contact($uid, $contacts[$post->source_id], $create_user);
+               } else
+                       $contact_id = fbsync_fetch_contact($uid, $contacts[$post->source_id], $create_user);
+
 
                if ($contact_id == -1) {
                        logger('fbsync_createpost: Contact is blocked. Post not imported '.print_r($post, true), LOGGER_DEBUG);