- /**
- * 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;
- }
-