}
// We now have some contact, so we fetch it
- $importer = DBA::fetchFirst("SELECT *, `name` as `senderName`
+ $importer = DBA::fetchFirst("SELECT *, `name` as `senderName`,
+ 0 AS `importer_uid`,
'' AS `uprvkey`,
'UTC' AS `timezone`,
'' AS `nickname`,
WHERE NOT `blocked` AND `id` = ? LIMIT 1",
$contact['id']);
- $importer['importer_uid'] = 0;
-
// This should never fail
if (!DBA::isResult($importer)) {
logger('Contact not found for address ' . $msg['author']);
$contact = [];
// if it's the url containing https it should be converted to http
$nurl = normalise_link(GContact::cleanContactUrl($profileurl));
- if ($nurl) {
- // Search for contact data
+ if (!$nurl) {
+ return;
+ }
+
+ // Search for contact data
+ // Look if the local user has got the contact
+ if (local_user()) {
+ $contact = Contact::getDetailsByURL($nurl, local_user());
+ }
+
+ // If not then check the global user
+ if (!count($contact)) {
$contact = Contact::getDetailsByURL($nurl);
}
+
+ // Feeds url could have been destroyed through "cleanContactUrl", so we now use the original url
+ if (!count($contact) && local_user()) {
+ $nurl = normalise_link($profileurl);
+ $contact = Contact::getDetailsByURL($nurl, local_user());
+ }
+
+ if (!count($contact)) {
+ $nurl = normalise_link($profileurl);
+ $contact = Contact::getDetailsByURL($nurl);
+ }
+
if (!count($contact)) {
return;
}
$item = Item::selectFirst($fields, $condition);
if (!DBA::isResult($item)) {
+ if (!isset($contact["url"])) {
+ logger('Missing URL: ' . System::callstack() . ' - ' . json_encode($contact));
+ }
+
$result = self::storeByGuid($guid, $contact["url"], $uid);
if (!$result) {