diff --git a/src/Model/APContact.php b/src/Model/APContact.php index 5c60ebae59..aa5dbe2f71 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -124,7 +124,7 @@ class APContact $apcontact = DBA::selectFirst('apcontact', [], ['addr' => $url]); } - if (DBA::isResult($apcontact) && ($apcontact['updated'] > $ref_update) && !empty($apcontact['pubkey'])) { + if (DBA::isResult($apcontact) && ($apcontact['updated'] > $ref_update) && !empty($apcontact['pubkey']) && !empty($apcontact['uri-id'])) { return $apcontact; } @@ -352,7 +352,7 @@ class APContact if (empty($apcontact['uuid'])) { $apcontact['uri-id'] = ItemURI::getIdByURI($apcontact['url']); } else { - $apcontact['uri-id'] = ItemURI::insert(['uri' => $apcontact['uri'], 'guid' => $apcontact['uuid']]); + $apcontact['uri-id'] = ItemURI::insert(['uri' => $apcontact['url'], 'guid' => $apcontact['uuid']]); } $apcontact['updated'] = DateTimeFormat::utcNow(); diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 30158c5b4f..0184861c3c 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1072,12 +1072,12 @@ class Contact return 0; } - $contact = self::getByURL($url, false, ['id', 'network'], $uid); + $contact = self::getByURL($url, false, ['id', 'network', 'uri-id'], $uid); if (!empty($contact)) { $contact_id = $contact["id"]; - if (empty($update)) { + if (empty($update) && (!empty($contact['uri-id']) || is_bool($update))) { Logger::debug('Contact found', ['url' => $url, 'uid' => $uid, 'update' => $update, 'cid' => $contact_id]); return $contact_id; } @@ -2157,7 +2157,7 @@ class Contact if (empty($guid)) { $ret['uri-id'] = ItemURI::getIdByURI($ret['url']); } else { - $ret['uri-id'] = ItemURI::insert(['uri' => $ret['uri'], 'guid' => $guid]); + $ret['uri-id'] = ItemURI::insert(['uri' => $ret['url'], 'guid' => $guid]); } $ret['nurl'] = Strings::normaliseLink($ret['url']);