Replaced more calls of "Probe::uri" with "Contact::getByURL"
This commit is contained in:
parent
dd85f48e0d
commit
70699878ee
3 changed files with 7 additions and 66 deletions
|
@ -26,10 +26,8 @@ use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Network\Probe;
|
|
||||||
use Friendica\Object\Search\ContactResult;
|
use Friendica\Object\Search\ContactResult;
|
||||||
use Friendica\Object\Search\ResultList;
|
use Friendica\Object\Search\ResultList;
|
||||||
use Friendica\Protocol\PortableContact;
|
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -64,8 +62,7 @@ class Search
|
||||||
if ((filter_var($user, FILTER_VALIDATE_EMAIL) && Network::isEmailDomainValid($user)) ||
|
if ((filter_var($user, FILTER_VALIDATE_EMAIL) && Network::isEmailDomainValid($user)) ||
|
||||||
(substr(Strings::normaliseLink($user), 0, 7) == "http://")) {
|
(substr(Strings::normaliseLink($user), 0, 7) == "http://")) {
|
||||||
|
|
||||||
/// @todo Possibly use "getIdForURL" instead?
|
$user_data = Contact::getByURL($user);
|
||||||
$user_data = Probe::uri($user);
|
|
||||||
if (empty($user_data)) {
|
if (empty($user_data)) {
|
||||||
return $emptyResultList;
|
return $emptyResultList;
|
||||||
}
|
}
|
||||||
|
@ -74,9 +71,6 @@ class Search
|
||||||
return $emptyResultList;
|
return $emptyResultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that we do have a contact entry
|
|
||||||
Contact::getIdForURL($user_data['url'] ?? '');
|
|
||||||
|
|
||||||
$contactDetails = Contact::getByURLForUser($user_data['url'] ?? '', local_user());
|
$contactDetails = Contact::getByURLForUser($user_data['url'] ?? '', local_user());
|
||||||
|
|
||||||
$result = new ContactResult(
|
$result = new ContactResult(
|
||||||
|
@ -87,7 +81,7 @@ class Search
|
||||||
$user_data['photo'] ?? '',
|
$user_data['photo'] ?? '',
|
||||||
$user_data['network'] ?? '',
|
$user_data['network'] ?? '',
|
||||||
$contactDetails['id'] ?? 0,
|
$contactDetails['id'] ?? 0,
|
||||||
0,
|
$user_data['id'] ?? 0,
|
||||||
$user_data['tags'] ?? ''
|
$user_data['tags'] ?? ''
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1617,59 +1617,6 @@ class OStatus
|
||||||
return $source;
|
return $source;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches contact data from the contact or the gcontact table
|
|
||||||
*
|
|
||||||
* @param string $url URL of the contact
|
|
||||||
* @param array $owner Contact data of the poster
|
|
||||||
*
|
|
||||||
* @return array Contact array
|
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
|
||||||
* @throws \ImagickException
|
|
||||||
*/
|
|
||||||
private static function contactEntry($url, array $owner)
|
|
||||||
{
|
|
||||||
$r = q(
|
|
||||||
"SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` IN (0, %d) ORDER BY `uid` DESC LIMIT 1",
|
|
||||||
DBA::escape(Strings::normaliseLink($url)),
|
|
||||||
intval($owner["uid"])
|
|
||||||
);
|
|
||||||
if (DBA::isResult($r)) {
|
|
||||||
$contact = $r[0];
|
|
||||||
$contact["uid"] = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DBA::isResult($r)) {
|
|
||||||
$gcontact = DBA::selectFirst('gcontact', [], ['nurl' => Strings::normaliseLink($url)]);
|
|
||||||
if (DBA::isResult($r)) {
|
|
||||||
$contact = $gcontact;
|
|
||||||
$contact["uid"] = -1;
|
|
||||||
$contact["success_update"] = $contact["updated"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DBA::isResult($r)) {
|
|
||||||
$contact = $owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($contact["poll"])) {
|
|
||||||
$data = Probe::uri($url);
|
|
||||||
$contact["poll"] = $data["poll"];
|
|
||||||
|
|
||||||
if (!$contact["alias"]) {
|
|
||||||
$contact["alias"] = $data["alias"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($contact["alias"])) {
|
|
||||||
$contact["alias"] = $contact["url"];
|
|
||||||
}
|
|
||||||
|
|
||||||
$contact['account-type'] = $owner['account-type'];
|
|
||||||
|
|
||||||
return $contact;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an entry element with reshared content
|
* Adds an entry element with reshared content
|
||||||
*
|
*
|
||||||
|
@ -1699,7 +1646,7 @@ class OStatus
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact = self::contactEntry($repeated_item['author-link'], $owner);
|
$contact = Contact::getByURL($repeated_item['author-link']) ?: $owner;
|
||||||
|
|
||||||
$title = $owner["nick"]." repeated a notice by ".$contact["nick"];
|
$title = $owner["nick"]." repeated a notice by ".$contact["nick"];
|
||||||
|
|
||||||
|
@ -1841,7 +1788,7 @@ class OStatus
|
||||||
$item["created"] = $item["edited"] = date("c");
|
$item["created"] = $item["edited"] = date("c");
|
||||||
$item["private"] = Item::PRIVATE;
|
$item["private"] = Item::PRIVATE;
|
||||||
|
|
||||||
$contact = Probe::uri($item['follow']);
|
$contact = Contact::getByURL($item['follow']);
|
||||||
$item['follow'] = $contact['url'];
|
$item['follow'] = $contact['url'];
|
||||||
|
|
||||||
if ($contact['alias']) {
|
if ($contact['alias']) {
|
||||||
|
@ -1948,7 +1895,7 @@ class OStatus
|
||||||
$entry = $doc->createElement("entry");
|
$entry = $doc->createElement("entry");
|
||||||
|
|
||||||
if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
|
if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
|
||||||
$contact = self::contactEntry($item['author-link'], $owner);
|
$contact = Contact::getByURL($item['author-link']) ?: $owner;
|
||||||
$author = self::addAuthor($doc, $contact, false);
|
$author = self::addAuthor($doc, $contact, false);
|
||||||
$entry->appendChild($author);
|
$entry->appendChild($author);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,9 @@ use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Search;
|
use Friendica\Core\Search;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
use Friendica\Model\GServer;
|
use Friendica\Model\GServer;
|
||||||
use Friendica\Network\Probe;
|
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class SearchDirectory
|
||||||
Logger::info('Friendica server seems to be okay.', ['server' => $server_url]);
|
Logger::info('Friendica server seems to be okay.', ['server' => $server_url]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = Probe::uri($jj->url);
|
$data = Contact::getByURL($jj->url);
|
||||||
if ($data['network'] == Protocol::DFRN) {
|
if ($data['network'] == Protocol::DFRN) {
|
||||||
Logger::info('Add profile to local directory', ['profile' => $jj->url]);
|
Logger::info('Add profile to local directory', ['profile' => $jj->url]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue