From 97fe8aef5cbd8f227c0bb79f3b31e94aab25cb0c Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 25 Jun 2014 09:11:09 +0200 Subject: [PATCH] fbsync: prevent falsely added copntacts --- fbsync/fbsync.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/fbsync/fbsync.php b/fbsync/fbsync.php index 14de4df25..bcd4e5a8d 100644 --- a/fbsync/fbsync.php +++ b/fbsync/fbsync.php @@ -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);