use Friendica\Protocol\PortableContact;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
-
-require_once 'include/dba.php';
+use Friendica\Util\Strings;
/**
* @brief This class handles GlobalContact related functions
$alternate = PortableContact::alternateOStatusUrl($gcontact['url']);
// The global contacts should contain the original picture, not the cached one
- if (($gcontact['generation'] != 1) && stristr(normalise_link($gcontact['photo']), normalise_link(System::baseUrl()."/photo/"))) {
+ if (($gcontact['generation'] != 1) && stristr(Strings::normaliseLink($gcontact['photo']), Strings::normaliseLink(System::baseUrl()."/photo/"))) {
$gcontact['photo'] = "";
}
if (!isset($gcontact['network'])) {
$condition = ["`uid` = 0 AND `nurl` = ? AND `network` != '' AND `network` != ?",
- normalise_link($gcontact['url']), Protocol::STATUSNET];
+ Strings::normaliseLink($gcontact['url']), Protocol::STATUSNET];
$contact = DBA::selectFirst('contact', ['network'], $condition);
if (DBA::isResult($contact)) {
$gcontact['network'] = $contact["network"];
if (($gcontact['network'] == "") || ($gcontact['network'] == Protocol::OSTATUS)) {
$condition = ["`uid` = 0 AND `alias` IN (?, ?) AND `network` != '' AND `network` != ?",
- $gcontact['url'], normalise_link($gcontact['url']), Protocol::STATUSNET];
+ $gcontact['url'], Strings::normaliseLink($gcontact['url']), Protocol::STATUSNET];
$contact = DBA::selectFirst('contact', ['network'], $condition);
if (DBA::isResult($contact)) {
$gcontact['network'] = $contact["network"];
$gcontact['network'] = '';
$fields = ['network', 'updated', 'server_url', 'url', 'addr'];
- $gcnt = DBA::selectFirst('gcontact', $fields, ['nurl' => normalise_link($gcontact['url'])]);
+ $gcnt = DBA::selectFirst('gcontact', $fields, ['nurl' => Strings::normaliseLink($gcontact['url'])]);
if (DBA::isResult($gcnt)) {
if (!isset($gcontact['network']) && ($gcnt["network"] != Protocol::STATUSNET)) {
$gcontact['network'] = $gcnt["network"];
if ($gcontact['updated'] <= DBA::NULL_DATETIME) {
$gcontact['updated'] = $gcnt["updated"];
}
- if (!isset($gcontact['server_url']) && (normalise_link($gcnt["server_url"]) != normalise_link($gcnt["url"]))) {
+ if (!isset($gcontact['server_url']) && (Strings::normaliseLink($gcnt["server_url"]) != Strings::normaliseLink($gcnt["url"]))) {
$gcontact['server_url'] = $gcnt["server_url"];
}
if (!isset($gcontact['addr'])) {
if ($alternate && ($gcontact['network'] == Protocol::OSTATUS)) {
// Delete the old entry - if it exists
- if (DBA::exists('gcontact', ['nurl' => normalise_link($orig_profile)])) {
- DBA::delete('gcontact', ['nurl' => normalise_link($orig_profile)]);
+ if (DBA::exists('gcontact', ['nurl' => Strings::normaliseLink($orig_profile)])) {
+ DBA::delete('gcontact', ['nurl' => Strings::normaliseLink($orig_profile)]);
}
}
}
// return $list;
//}
- $network = [Protocol::DFRN];
+ $network = [Protocol::DFRN, Protocol::ACTIVITYPUB];
if (Config::get('system', 'diaspora_enabled')) {
$network[] = Protocol::DIASPORA;
where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d )
AND NOT `gcontact`.`name` IN (SELECT `name` FROM `contact` WHERE `uid` = %d)
AND NOT `gcontact`.`id` IN (SELECT `gcid` FROM `gcign` WHERE `uid` = %d)
- AND `gcontact`.`updated` >= '%s'
+ AND `gcontact`.`updated` >= '%s' AND NOT `gcontact`.`hide`
AND `gcontact`.`last_contact` >= `gcontact`.`last_failure`
AND `gcontact`.`network` IN (%s)
GROUP BY `glink`.`gcid` ORDER BY `gcontact`.`updated` DESC,`total` DESC LIMIT %d, %d",
*/
public static function updateSuggestions()
{
- $a = get_app();
+ $a = \get_app();
$done = [];
}
if ($new_url != $url) {
- Logger::log("Cleaned contact url ".$url." to ".$new_url." - Called by: ".System::callstack(), LOGGER_DEBUG);
+ Logger::log("Cleaned contact url ".$url." to ".$new_url." - Called by: ".System::callstack(), Logger::DEBUG);
}
return $new_url;
if (($contact["network"] == Protocol::OSTATUS) && PortableContact::alternateOStatusUrl($contact["url"])) {
$data = Probe::uri($contact["url"]);
if ($contact["network"] == Protocol::OSTATUS) {
- Logger::log("Fix primary url from ".$contact["url"]." to ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
+ Logger::log("Fix primary url from ".$contact["url"]." to ".$data["url"]." - Called by: ".System::callstack(), Logger::DEBUG);
$contact["url"] = $data["url"];
$contact["addr"] = $data["addr"];
$contact["alias"] = $data["alias"];
$last_contact_str = '';
if (empty($contact["network"])) {
- Logger::log("Empty network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
+ Logger::log("Empty network for contact url ".$contact["url"]." - Called by: ".System::callstack(), Logger::DEBUG);
return false;
}
if (in_array($contact["network"], [Protocol::PHANTOM])) {
- Logger::log("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
+ Logger::log("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), Logger::DEBUG);
return false;
}
DBA::lock('gcontact');
$fields = ['id', 'last_contact', 'last_failure', 'network'];
- $gcnt = DBA::selectFirst('gcontact', $fields, ['nurl' => normalise_link($contact["url"])]);
+ $gcnt = DBA::selectFirst('gcontact', $fields, ['nurl' => Strings::normaliseLink($contact["url"])]);
if (DBA::isResult($gcnt)) {
$gcontact_id = $gcnt["id"];
DBA::escape($contact["addr"]),
DBA::escape($contact["network"]),
DBA::escape($contact["url"]),
- DBA::escape(normalise_link($contact["url"])),
+ DBA::escape(Strings::normaliseLink($contact["url"])),
DBA::escape($contact["photo"]),
DBA::escape(DateTimeFormat::utcNow()),
DBA::escape(DateTimeFormat::utcNow()),
intval($contact["generation"])
);
- $condition = ['nurl' => normalise_link($contact["url"])];
+ $condition = ['nurl' => Strings::normaliseLink($contact["url"])];
$cnt = DBA::selectFirst('gcontact', ['id', 'network'], $condition, ['order' => ['id']]);
if (DBA::isResult($cnt)) {
$gcontact_id = $cnt["id"];
DBA::unlock();
if ($doprobing) {
- Logger::log("Last Contact: ". $last_contact_str." - Last Failure: ".$last_failure_str." - Checking: ".$contact["url"], LOGGER_DEBUG);
+ Logger::log("Last Contact: ". $last_contact_str." - Last Failure: ".$last_failure_str." - Checking: ".$contact["url"], Logger::DEBUG);
Worker::add(PRIORITY_LOW, 'GProbe', $contact["url"]);
}
$contact["server_url"] = $data['baseurl'];
}
} else {
- $contact["server_url"] = normalise_link($contact["server_url"]);
+ $contact["server_url"] = Strings::normaliseLink($contact["server_url"]);
}
if (($contact["addr"] == "") && ($contact["server_url"] != "") && ($contact["nick"] != "")) {
if ((($contact["generation"] > 0) && ($contact["generation"] <= $public_contact[0]["generation"])) || ($public_contact[0]["generation"] == 0)) {
foreach ($fields as $field => $data) {
if ($contact[$field] != $public_contact[0][$field]) {
- Logger::log("Difference for contact ".$contact["url"]." in field '".$field."'. New value: '".$contact[$field]."', old value '".$public_contact[0][$field]."'", LOGGER_DEBUG);
+ Logger::log("Difference for contact ".$contact["url"]." in field '".$field."'. New value: '".$contact[$field]."', old value '".$public_contact[0][$field]."'", Logger::DEBUG);
$update = true;
}
}
if ($contact["generation"] < $public_contact[0]["generation"]) {
- Logger::log("Difference for contact ".$contact["url"]." in field 'generation'. new value: '".$contact["generation"]."', old value '".$public_contact[0]["generation"]."'", LOGGER_DEBUG);
+ Logger::log("Difference for contact ".$contact["url"]." in field 'generation'. new value: '".$contact["generation"]."', old value '".$public_contact[0]["generation"]."'", Logger::DEBUG);
$update = true;
}
}
if ($update) {
- Logger::log("Update gcontact for ".$contact["url"], LOGGER_DEBUG);
+ Logger::log("Update gcontact for ".$contact["url"], Logger::DEBUG);
$condition = ['`nurl` = ? AND (`generation` = 0 OR `generation` >= ?)',
- normalise_link($contact["url"]), $contact["generation"]];
+ Strings::normaliseLink($contact["url"]), $contact["generation"]];
$contact["updated"] = DateTimeFormat::utc($contact["updated"]);
$updated = ['photo' => $contact['photo'], 'name' => $contact['name'],
// This is used for the shadow copies of public items.
/// @todo Check if we really should do this.
// The quality of the gcontact table is mostly lower than the public contact
- $public_contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link($contact["url"]), 'uid' => 0]);
+ $public_contact = DBA::selectFirst('contact', ['id'], ['nurl' => Strings::normaliseLink($contact["url"]), 'uid' => 0]);
if (DBA::isResult($public_contact)) {
- Logger::log("Update public contact ".$public_contact["id"], LOGGER_DEBUG);
+ Logger::log("Update public contact ".$public_contact["id"], Logger::DEBUG);
Contact::updateAvatar($contact["photo"], 0, $public_contact["id"]);
'location' => $contact['location'], 'about' => $contact['about']];
// Don't update the birthday field if not set or invalid
- if (empty($contact['birthday']) || ($contact['birthday'] < '0001-01-01')) {
+ if (empty($contact['birthday']) || ($contact['birthday'] <= DBA::NULL_DATE)) {
unset($fields['bd']);
}
$data = Probe::uri($url);
if (in_array($data["network"], [Protocol::PHANTOM])) {
- Logger::log("Invalid network for contact url ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
+ Logger::log("Invalid network for contact url ".$data["url"]." - Called by: ".System::callstack(), Logger::DEBUG);
return;
}
);
if (!DBA::isResult($r)) {
- Logger::log('Cannot find user with uid=' . $uid, LOGGER_INFO);
+ Logger::log('Cannot find user with uid=' . $uid, Logger::INFO);
return false;
}
*/
public static function fetchGsUsers($server)
{
- Logger::log("Fetching users from GNU Social server ".$server, LOGGER_DEBUG);
+ Logger::log("Fetching users from GNU Social server ".$server, Logger::DEBUG);
$url = $server."/main/statistics";
$statistics = json_decode($curlResult->getBody());
- if (!empty($statistics->config)) {
- if ($statistics->config->instance_with_ssl) {
+ if (!empty($statistics->config->instance_address)) {
+ if (!empty($statistics->config->instance_with_ssl)) {
$server = "https://";
} else {
$server = "http://";
$server .= $statistics->config->instance_address;
$hostname = $statistics->config->instance_address;
- } elseif (!empty($statistics)) {
- if ($statistics->instance_with_ssl) {
+ } elseif (!empty($statistics->instance_address)) {
+ if (!empty($statistics->instance_with_ssl)) {
$server = "https://";
} else {
$server = "http://";