$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;
}
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();
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;
}
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']);