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);