mirror of
https://github.com/friendica/friendica
synced 2025-04-28 17:04:23 +02:00
normalise_link calls
implement normaliseLink function
This commit is contained in:
parent
5276c28a78
commit
ffc406d819
54 changed files with 248 additions and 222 deletions
|
@ -5,6 +5,8 @@
|
|||
namespace Friendica\Protocol\ActivityPub;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Model\Conversation;
|
||||
|
@ -13,11 +15,10 @@ use Friendica\Model\APContact;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Event;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Util\JsonLD;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\JsonLD;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
/**
|
||||
* ActivityPub Processor Protocol class
|
||||
|
@ -417,7 +418,7 @@ class Processor
|
|||
return;
|
||||
}
|
||||
|
||||
$contacts = DBA::select('contact', ['id'], ['nurl' => normalise_link($activity['object_id'])]);
|
||||
$contacts = DBA::select('contact', ['id'], ['nurl' => Strings::normaliseLink($activity['object_id'])]);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
Contact::remove($contact['id']);
|
||||
}
|
||||
|
|
|
@ -5,18 +5,19 @@
|
|||
namespace Friendica\Protocol\ActivityPub;
|
||||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\HTTPSignature;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\APContact;
|
||||
use Friendica\Model\Conversation;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\HTTPSignature;
|
||||
use Friendica\Util\JsonLD;
|
||||
use Friendica\Util\LDSignature;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Model\Conversation;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
/**
|
||||
* @brief ActivityPub Receiver Protocol class
|
||||
|
@ -455,7 +456,7 @@ class Receiver
|
|||
|
||||
if (($receiver == self::PUBLIC_COLLECTION) && !empty($actor)) {
|
||||
// This will most likely catch all OStatus connections to Mastodon
|
||||
$condition = ['alias' => [$actor, normalise_link($actor)], 'rel' => [Contact::SHARING, Contact::FRIEND]
|
||||
$condition = ['alias' => [$actor, Strings::normaliseLink($actor)], 'rel' => [Contact::SHARING, Contact::FRIEND]
|
||||
, 'archive' => false, 'pending' => false];
|
||||
$contacts = DBA::select('contact', ['uid'], $condition);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
|
@ -472,7 +473,7 @@ class Receiver
|
|||
}
|
||||
|
||||
// Fetching all directly addressed receivers
|
||||
$condition = ['self' => true, 'nurl' => normalise_link($receiver)];
|
||||
$condition = ['self' => true, 'nurl' => Strings::normaliseLink($receiver)];
|
||||
$contact = DBA::selectFirst('contact', ['uid', 'contact-type'], $condition);
|
||||
if (!DBA::isResult($contact)) {
|
||||
continue;
|
||||
|
@ -482,7 +483,7 @@ class Receiver
|
|||
// Exception: The receiver is targetted via "to" or this is a comment
|
||||
if ((($element != 'as:to') && empty($replyto)) || ($contact['contact-type'] == Contact::ACCOUNT_TYPE_COMMUNITY)) {
|
||||
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
|
||||
$condition = ['nurl' => normalise_link($actor), 'rel' => [Contact::SHARING, Contact::FRIEND],
|
||||
$condition = ['nurl' => Strings::normaliseLink($actor), 'rel' => [Contact::SHARING, Contact::FRIEND],
|
||||
'network' => $networks, 'archive' => false, 'pending' => false, 'uid' => $contact['uid']];
|
||||
|
||||
// Forum posts are only accepted from forum contacts
|
||||
|
@ -516,7 +517,7 @@ class Receiver
|
|||
{
|
||||
$receivers = [];
|
||||
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
|
||||
$condition = ['nurl' => normalise_link($actor), 'rel' => [Contact::SHARING, Contact::FRIEND, Contact::FOLLOWER],
|
||||
$condition = ['nurl' => Strings::normaliseLink($actor), 'rel' => [Contact::SHARING, Contact::FRIEND, Contact::FOLLOWER],
|
||||
'network' => $networks, 'archive' => false, 'pending' => false];
|
||||
$contacts = DBA::select('contact', ['uid', 'rel'], $condition);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
|
@ -589,7 +590,7 @@ class Receiver
|
|||
unset($profile['photo']);
|
||||
unset($profile['baseurl']);
|
||||
|
||||
$profile['nurl'] = normalise_link($profile['url']);
|
||||
$profile['nurl'] = Strings::normaliseLink($profile['url']);
|
||||
DBA::update('contact', $profile, ['id' => $cid]);
|
||||
|
||||
Contact::updateAvatar($photo, $uid, $cid);
|
||||
|
@ -614,12 +615,12 @@ class Receiver
|
|||
}
|
||||
|
||||
foreach ($receivers as $receiver) {
|
||||
$contact = DBA::selectFirst('contact', ['id'], ['uid' => $receiver, 'network' => Protocol::OSTATUS, 'nurl' => normalise_link($actor)]);
|
||||
$contact = DBA::selectFirst('contact', ['id'], ['uid' => $receiver, 'network' => Protocol::OSTATUS, 'nurl' => Strings::normaliseLink($actor)]);
|
||||
if (DBA::isResult($contact)) {
|
||||
self::switchContact($contact['id'], $receiver, $actor);
|
||||
}
|
||||
|
||||
$contact = DBA::selectFirst('contact', ['id'], ['uid' => $receiver, 'network' => Protocol::OSTATUS, 'alias' => [normalise_link($actor), $actor]]);
|
||||
$contact = DBA::selectFirst('contact', ['id'], ['uid' => $receiver, 'network' => Protocol::OSTATUS, 'alias' => [Strings::normaliseLink($actor), $actor]]);
|
||||
if (DBA::isResult($contact)) {
|
||||
self::switchContact($contact['id'], $receiver, $actor);
|
||||
}
|
||||
|
|
|
@ -1097,7 +1097,7 @@ class DFRN
|
|||
}
|
||||
|
||||
foreach ($mentioned as $mention) {
|
||||
$condition = ['uid' => $owner["uid"], 'nurl' => normalise_link($mention)];
|
||||
$condition = ['uid' => $owner["uid"], 'nurl' => Strings::normaliseLink($mention)];
|
||||
$contact = DBA::selectFirst('contact', ['forum', 'prv'], $condition);
|
||||
|
||||
if (DBA::isResult($contact) && ($contact["forum"] || $contact["prv"])) {
|
||||
|
@ -1569,7 +1569,7 @@ class DFRN
|
|||
$fields = ['id', 'uid', 'url', 'network', 'avatar-date', 'avatar', 'name-date', 'uri-date', 'addr',
|
||||
'name', 'nick', 'about', 'location', 'keywords', 'xmpp', 'bdyear', 'bd', 'hidden', 'contact-type'];
|
||||
$condition = ["`uid` = ? AND `nurl` = ? AND `network` != ?",
|
||||
$importer["importer_uid"], normalise_link($author["link"]), Protocol::STATUSNET];
|
||||
$importer["importer_uid"], Strings::normaliseLink($author["link"]), Protocol::STATUSNET];
|
||||
$contact_old = DBA::selectFirst('contact', $fields, $condition);
|
||||
|
||||
if (DBA::isResult($contact_old)) {
|
||||
|
@ -1960,7 +1960,7 @@ class DFRN
|
|||
*
|
||||
* @see https://github.com/friendica/friendica/pull/3254#discussion_r107315246
|
||||
*/
|
||||
$condition = ['name' => $suggest["name"], 'nurl' => normalise_link($suggest["url"]),
|
||||
$condition = ['name' => $suggest["name"], 'nurl' => Strings::normaliseLink($suggest["url"]),
|
||||
'uid' => $suggest["uid"]];
|
||||
if (DBA::exists('contact', $condition)) {
|
||||
return false;
|
||||
|
@ -2100,18 +2100,18 @@ class DFRN
|
|||
$relocate["server_url"] = preg_replace("=(https?://)(.*)/profile/(.*)=ism", "$1$2", $relocate["url"]);
|
||||
|
||||
$fields = ['name' => $relocate["name"], 'photo' => $relocate["avatar"],
|
||||
'url' => $relocate["url"], 'nurl' => normalise_link($relocate["url"]),
|
||||
'url' => $relocate["url"], 'nurl' => Strings::normaliseLink($relocate["url"]),
|
||||
'addr' => $relocate["addr"], 'connect' => $relocate["addr"],
|
||||
'notify' => $relocate["notify"], 'server_url' => $relocate["server_url"]];
|
||||
DBA::update('gcontact', $fields, ['nurl' => normalise_link($old["url"])]);
|
||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($old["url"])]);
|
||||
|
||||
// Update the contact table. We try to find every entry.
|
||||
$fields = ['name' => $relocate["name"], 'avatar' => $relocate["avatar"],
|
||||
'url' => $relocate["url"], 'nurl' => normalise_link($relocate["url"]),
|
||||
'url' => $relocate["url"], 'nurl' => Strings::normaliseLink($relocate["url"]),
|
||||
'addr' => $relocate["addr"], 'request' => $relocate["request"],
|
||||
'confirm' => $relocate["confirm"], 'notify' => $relocate["notify"],
|
||||
'poll' => $relocate["poll"], 'site-pubkey' => $relocate["sitepubkey"]];
|
||||
$condition = ["(`id` = ?) OR (`nurl` = ?)", $importer["id"], normalise_link($old["url"])];
|
||||
$condition = ["(`id` = ?) OR (`nurl` = ?)", $importer["id"], Strings::normaliseLink($old["url"])];
|
||||
|
||||
DBA::update('contact', $fields, $condition);
|
||||
|
||||
|
@ -2986,7 +2986,7 @@ class DFRN
|
|||
return;
|
||||
}
|
||||
$baseurl = substr($baseurl, $domain_st + 3);
|
||||
$nurl = normalise_link($baseurl);
|
||||
$nurl = Strings::normaliseLink($baseurl);
|
||||
|
||||
/// @todo Why is there a query for "url" *and* "nurl"? Especially this normalising is strange.
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = (SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1)
|
||||
|
@ -3079,13 +3079,13 @@ class DFRN
|
|||
$community_page = ($user['page-flags'] == Contact::PAGE_COMMUNITY);
|
||||
$prvgroup = ($user['page-flags'] == Contact::PAGE_PRVGROUP);
|
||||
|
||||
$link = normalise_link(System::baseUrl() . '/profile/' . $user['nickname']);
|
||||
$link = Strings::normaliseLink(System::baseUrl() . '/profile/' . $user['nickname']);
|
||||
|
||||
/*
|
||||
* Diaspora uses their own hardwired link URL in @-tags
|
||||
* instead of the one we supply with webfinger
|
||||
*/
|
||||
$dlink = normalise_link(System::baseUrl() . '/u/' . $user['nickname']);
|
||||
$dlink = Strings::normaliseLink(System::baseUrl() . '/u/' . $user['nickname']);
|
||||
|
||||
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism', $item['body'], $matches, PREG_SET_ORDER);
|
||||
if ($cnt) {
|
||||
|
|
|
@ -147,7 +147,7 @@ class Diaspora
|
|||
$fields = ['batch', 'id', 'name', 'network', 'archive', 'blocked'];
|
||||
|
||||
// Fetch the relay contact
|
||||
$condition = ['uid' => 0, 'nurl' => normalise_link($server_url),
|
||||
$condition = ['uid' => 0, 'nurl' => Strings::normaliseLink($server_url),
|
||||
'contact-type' => Contact::ACCOUNT_TYPE_RELAY];
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
|
||||
|
@ -186,7 +186,7 @@ class Diaspora
|
|||
|
||||
$fields = array_merge($fields, $network_fields);
|
||||
|
||||
$condition = ['uid' => 0, 'nurl' => normalise_link($server_url),
|
||||
$condition = ['uid' => 0, 'nurl' => Strings::normaliseLink($server_url),
|
||||
'contact-type' => Contact::ACCOUNT_TYPE_RELAY];
|
||||
|
||||
if (DBA::exists('contact', $condition)) {
|
||||
|
@ -1434,7 +1434,7 @@ class Diaspora
|
|||
*/
|
||||
private static function authorContactByUrl($def_contact, $person, $uid)
|
||||
{
|
||||
$condition = ['nurl' => normalise_link($person["url"]), 'uid' => $uid];
|
||||
$condition = ['nurl' => Strings::normaliseLink($person["url"]), 'uid' => $uid];
|
||||
$contact = DBA::selectFirst('contact', ['id', 'network'], $condition);
|
||||
if (DBA::isResult($contact)) {
|
||||
$cid = $contact["id"];
|
||||
|
@ -1536,7 +1536,7 @@ class Diaspora
|
|||
return false;
|
||||
}
|
||||
|
||||
$fields = ['url' => $data['url'], 'nurl' => normalise_link($data['url']),
|
||||
$fields = ['url' => $data['url'], 'nurl' => Strings::normaliseLink($data['url']),
|
||||
'name' => $data['name'], 'nick' => $data['nick'],
|
||||
'addr' => $data['addr'], 'batch' => $data['batch'],
|
||||
'notify' => $data['notify'], 'poll' => $data['poll'],
|
||||
|
@ -1544,7 +1544,7 @@ class Diaspora
|
|||
|
||||
DBA::update('contact', $fields, ['addr' => $old_handle]);
|
||||
|
||||
$fields = ['url' => $data['url'], 'nurl' => normalise_link($data['url']),
|
||||
$fields = ['url' => $data['url'], 'nurl' => Strings::normaliseLink($data['url']),
|
||||
'name' => $data['name'], 'nick' => $data['nick'],
|
||||
'addr' => $data['addr'], 'connect' => $data['addr'],
|
||||
'notify' => $data['notify'], 'photo' => $data['photo'],
|
||||
|
@ -2392,7 +2392,7 @@ class Diaspora
|
|||
DBA::escape($ret["addr"]),
|
||||
DateTimeFormat::utcNow(),
|
||||
DBA::escape($ret["url"]),
|
||||
DBA::escape(normalise_link($ret["url"])),
|
||||
DBA::escape(Strings::normaliseLink($ret["url"])),
|
||||
DBA::escape($batch),
|
||||
DBA::escape($ret["name"]),
|
||||
DBA::escape($ret["nick"]),
|
||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\Object\Image;
|
|||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
|
@ -98,7 +99,7 @@ class OStatus
|
|||
}
|
||||
|
||||
$condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ? AND `rel` IN (?, ?)",
|
||||
$importer["uid"], normalise_link($author["author-link"]), normalise_link($aliaslink),
|
||||
$importer["uid"], Strings::normaliseLink($author["author-link"]), Strings::normaliseLink($aliaslink),
|
||||
Protocol::STATUSNET, Contact::SHARING, Contact::FRIEND];
|
||||
$contact = DBA::selectFirst('contact', [], $condition);
|
||||
}
|
||||
|
@ -164,7 +165,7 @@ class OStatus
|
|||
// $contact["poll"] = $value;
|
||||
|
||||
$contact['url'] = $author["author-link"];
|
||||
$contact['nurl'] = normalise_link($contact['url']);
|
||||
$contact['nurl'] = Strings::normaliseLink($contact['url']);
|
||||
|
||||
$value = XML::getFirstNodeValue($xpath, 'atom:author/atom:uri/text()', $context);
|
||||
if ($value != "") {
|
||||
|
@ -209,7 +210,7 @@ class OStatus
|
|||
|
||||
// Update it with the current values
|
||||
$fields = ['url' => $author["author-link"], 'name' => $contact["name"],
|
||||
'nurl' => normalise_link($author["author-link"]),
|
||||
'nurl' => Strings::normaliseLink($author["author-link"]),
|
||||
'nick' => $contact["nick"], 'alias' => $contact["alias"],
|
||||
'about' => $contact["about"], 'location' => $contact["location"],
|
||||
'success_update' => DateTimeFormat::utcNow(), 'last-update' => DateTimeFormat::utcNow()];
|
||||
|
@ -1599,7 +1600,7 @@ class OStatus
|
|||
{
|
||||
$r = q(
|
||||
"SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` IN (0, %d) ORDER BY `uid` DESC LIMIT 1",
|
||||
DBA::escape(normalise_link($url)),
|
||||
DBA::escape(Strings::normaliseLink($url)),
|
||||
intval($owner["uid"])
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
|
@ -1608,7 +1609,7 @@ class OStatus
|
|||
}
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
$gcontact = DBA::selectFirst('gcontact', [], ['nurl' => normalise_link($url)]);
|
||||
$gcontact = DBA::selectFirst('gcontact', [], ['nurl' => Strings::normaliseLink($url)]);
|
||||
if (DBA::isResult($r)) {
|
||||
$contact = $gcontact;
|
||||
$contact["uid"] = -1;
|
||||
|
@ -1651,7 +1652,7 @@ class OStatus
|
|||
*/
|
||||
private static function reshareEntry(DOMDocument $doc, array $item, array $owner, $repeated_guid, $toplevel)
|
||||
{
|
||||
if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) {
|
||||
if (($item["id"] != $item["parent"]) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
|
||||
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
|
||||
}
|
||||
|
||||
|
@ -1714,7 +1715,7 @@ class OStatus
|
|||
*/
|
||||
private static function likeEntry(DOMDocument $doc, array $item, array $owner, $toplevel)
|
||||
{
|
||||
if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) {
|
||||
if (($item["id"] != $item["parent"]) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
|
||||
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
|
||||
}
|
||||
|
||||
|
@ -1811,7 +1812,7 @@ class OStatus
|
|||
$item['follow'] = $contact['alias'];
|
||||
}
|
||||
|
||||
$condition = ['uid' => $owner['uid'], 'nurl' => normalise_link($contact["url"])];
|
||||
$condition = ['uid' => $owner['uid'], 'nurl' => Strings::normaliseLink($contact["url"])];
|
||||
$user_contact = DBA::selectFirst('contact', ['id'], $condition);
|
||||
|
||||
if (DBA::isResult($user_contact)) {
|
||||
|
@ -1861,7 +1862,7 @@ class OStatus
|
|||
*/
|
||||
private static function noteEntry(DOMDocument $doc, array $item, array $owner, $toplevel)
|
||||
{
|
||||
if (($item["id"] != $item["parent"]) && (normalise_link($item["author-link"]) != normalise_link($owner["url"]))) {
|
||||
if (($item["id"] != $item["parent"]) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
|
||||
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
|
||||
}
|
||||
|
||||
|
@ -2048,7 +2049,7 @@ class OStatus
|
|||
$mentioned = $newmentions;
|
||||
|
||||
foreach ($mentioned as $mention) {
|
||||
$condition = ['uid' => $owner['uid'], 'nurl' => normalise_link($mention)];
|
||||
$condition = ['uid' => $owner['uid'], 'nurl' => Strings::normaliseLink($mention)];
|
||||
$contact = DBA::selectFirst('contact', ['forum', 'prv', 'self', 'contact-type'], $condition);
|
||||
if ($contact["forum"] || $contact["prv"] || ($owner['contact-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) ||
|
||||
($contact['self'] && ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY))) {
|
||||
|
|
|
@ -23,6 +23,7 @@ use Friendica\Model\Profile;
|
|||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
|
@ -284,7 +285,7 @@ class PortableContact
|
|||
|
||||
$r = q(
|
||||
"SELECT `id` FROM `gserver` WHERE `nurl` = '%s' AND `last_contact` > `last_failure`",
|
||||
DBA::escape(normalise_link($server_url))
|
||||
DBA::escape(Strings::normaliseLink($server_url))
|
||||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
|
@ -309,7 +310,7 @@ class PortableContact
|
|||
{
|
||||
$gcontacts = q(
|
||||
"SELECT * FROM `gcontact` WHERE `nurl` = '%s'",
|
||||
DBA::escape(normalise_link($profile))
|
||||
DBA::escape(Strings::normaliseLink($profile))
|
||||
);
|
||||
|
||||
if (!DBA::isResult($gcontacts)) {
|
||||
|
@ -324,7 +325,7 @@ class PortableContact
|
|||
|
||||
$server_url = '';
|
||||
if ($force) {
|
||||
$server_url = normalise_link(self::detectServer($profile));
|
||||
$server_url = Strings::normaliseLink(self::detectServer($profile));
|
||||
}
|
||||
|
||||
if (($server_url == '') && ($gcontacts[0]["server_url"] != "")) {
|
||||
|
@ -332,7 +333,7 @@ class PortableContact
|
|||
}
|
||||
|
||||
if (!$force && (($server_url == '') || ($gcontacts[0]["server_url"] == $gcontacts[0]["nurl"]))) {
|
||||
$server_url = normalise_link(self::detectServer($profile));
|
||||
$server_url = Strings::normaliseLink(self::detectServer($profile));
|
||||
}
|
||||
|
||||
if (!in_array($gcontacts[0]["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) {
|
||||
|
@ -344,7 +345,7 @@ class PortableContact
|
|||
if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) {
|
||||
if ($force) {
|
||||
$fields = ['last_failure' => DateTimeFormat::utcNow()];
|
||||
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($profile)]);
|
||||
}
|
||||
|
||||
Logger::log("Profile ".$profile.": Server ".$server_url." wasn't reachable.", Logger::DEBUG);
|
||||
|
@ -356,7 +357,7 @@ class PortableContact
|
|||
if (in_array($gcontacts[0]["network"], ["", Protocol::FEED])) {
|
||||
$server = q(
|
||||
"SELECT `network` FROM `gserver` WHERE `nurl` = '%s' AND `network` != ''",
|
||||
DBA::escape(normalise_link($server_url))
|
||||
DBA::escape(Strings::normaliseLink($server_url))
|
||||
);
|
||||
|
||||
if ($server) {
|
||||
|
@ -369,7 +370,7 @@ class PortableContact
|
|||
// noscrape is really fast so we don't cache the call.
|
||||
if (($server_url != "") && ($gcontacts[0]["nick"] != "")) {
|
||||
// Use noscrape if possible
|
||||
$server = q("SELECT `noscrape`, `network` FROM `gserver` WHERE `nurl` = '%s' AND `noscrape` != ''", DBA::escape(normalise_link($server_url)));
|
||||
$server = q("SELECT `noscrape`, `network` FROM `gserver` WHERE `nurl` = '%s' AND `noscrape` != ''", DBA::escape(Strings::normaliseLink($server_url)));
|
||||
|
||||
if ($server) {
|
||||
$curlResult = Network::curl($server[0]["noscrape"]."/".$gcontacts[0]["nick"]);
|
||||
|
@ -425,7 +426,7 @@ class PortableContact
|
|||
|
||||
if (!empty($noscrape["updated"])) {
|
||||
$fields = ['last_contact' => DateTimeFormat::utcNow()];
|
||||
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($profile)]);
|
||||
|
||||
Logger::log("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", Logger::DEBUG);
|
||||
|
||||
|
@ -449,11 +450,11 @@ class PortableContact
|
|||
// Is the profile link the alternate OStatus link notation? (http://domain.tld/user/4711)
|
||||
// Then check the other link and delete this one
|
||||
if (($data["network"] == Protocol::OSTATUS) && self::alternateOStatusUrl($profile)
|
||||
&& (normalise_link($profile) == normalise_link($data["alias"]))
|
||||
&& (normalise_link($profile) != normalise_link($data["url"]))
|
||||
&& (Strings::normaliseLink($profile) == Strings::normaliseLink($data["alias"]))
|
||||
&& (Strings::normaliseLink($profile) != Strings::normaliseLink($data["url"]))
|
||||
) {
|
||||
// Delete the old entry
|
||||
DBA::delete('gcontact', ['nurl' => normalise_link($profile)]);
|
||||
DBA::delete('gcontact', ['nurl' => Strings::normaliseLink($profile)]);
|
||||
|
||||
$gcontact = array_merge($gcontacts[0], $data);
|
||||
|
||||
|
@ -474,7 +475,7 @@ class PortableContact
|
|||
|
||||
if (($data["poll"] == "") || (in_array($data["network"], [Protocol::FEED, Protocol::PHANTOM]))) {
|
||||
$fields = ['last_failure' => DateTimeFormat::utcNow()];
|
||||
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($profile)]);
|
||||
|
||||
Logger::log("Profile ".$profile." wasn't reachable (profile)", Logger::DEBUG);
|
||||
return false;
|
||||
|
@ -490,7 +491,7 @@ class PortableContact
|
|||
|
||||
if (!$curlResult->isSuccess()) {
|
||||
$fields = ['last_failure' => DateTimeFormat::utcNow()];
|
||||
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($profile)]);
|
||||
|
||||
Logger::log("Profile ".$profile." wasn't reachable (no feed)", Logger::DEBUG);
|
||||
return false;
|
||||
|
@ -533,11 +534,11 @@ class PortableContact
|
|||
$fields['updated'] = $last_updated;
|
||||
}
|
||||
|
||||
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($profile)]);
|
||||
|
||||
if (($gcontacts[0]["generation"] == 0)) {
|
||||
$fields = ['generation' => 9];
|
||||
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($profile)]);
|
||||
}
|
||||
|
||||
Logger::log("Profile ".$profile." was last updated at ".$last_updated, Logger::DEBUG);
|
||||
|
@ -930,11 +931,11 @@ class PortableContact
|
|||
return false;
|
||||
}
|
||||
|
||||
$gserver = DBA::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
|
||||
$gserver = DBA::selectFirst('gserver', [], ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
if ($gserver["created"] <= DBA::NULL_DATETIME) {
|
||||
$fields = ['created' => DateTimeFormat::utcNow()];
|
||||
$condition = ['nurl' => normalise_link($server_url)];
|
||||
$condition = ['nurl' => Strings::normaliseLink($server_url)];
|
||||
DBA::update('gserver', $fields, $condition);
|
||||
}
|
||||
$poco = $gserver["poco"];
|
||||
|
@ -990,7 +991,7 @@ class PortableContact
|
|||
// Mastodon uses the "@" for user profiles.
|
||||
// But this can be misunderstood.
|
||||
if (parse_url($server_url, PHP_URL_USER) != '') {
|
||||
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
|
||||
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1006,7 +1007,7 @@ class PortableContact
|
|||
if (DBA::isResult($gserver) && ($orig_server_url == $server_url) &&
|
||||
($curlResult->isTimeout())) {
|
||||
Logger::log("Connection to server ".$server_url." timed out.", Logger::DEBUG);
|
||||
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
|
||||
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1021,7 +1022,7 @@ class PortableContact
|
|||
// Quit if there is a timeout
|
||||
if ($curlResult->isTimeout()) {
|
||||
Logger::log("Connection to server " . $server_url . " timed out.", Logger::DEBUG);
|
||||
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
|
||||
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1048,7 +1049,7 @@ class PortableContact
|
|||
|
||||
if (!$failure) {
|
||||
// This will be too low, but better than no value at all.
|
||||
$registered_users = DBA::count('gcontact', ['server_url' => normalise_link($server_url)]);
|
||||
$registered_users = DBA::count('gcontact', ['server_url' => Strings::normaliseLink($server_url)]);
|
||||
}
|
||||
|
||||
// Look for poco
|
||||
|
@ -1410,7 +1411,7 @@ class PortableContact
|
|||
}
|
||||
|
||||
// Check again if the server exists
|
||||
$found = DBA::exists('gserver', ['nurl' => normalise_link($server_url)]);
|
||||
$found = DBA::exists('gserver', ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
|
||||
$version = strip_tags($version);
|
||||
$site_name = strip_tags($site_name);
|
||||
|
@ -1424,9 +1425,9 @@ class PortableContact
|
|||
'last_contact' => $last_contact, 'last_failure' => $last_failure];
|
||||
|
||||
if ($found) {
|
||||
DBA::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
|
||||
DBA::update('gserver', $fields, ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
} elseif (!$failure) {
|
||||
$fields['nurl'] = normalise_link($server_url);
|
||||
$fields['nurl'] = Strings::normaliseLink($server_url);
|
||||
$fields['created'] = DateTimeFormat::utcNow();
|
||||
DBA::insert('gserver', $fields);
|
||||
}
|
||||
|
@ -1461,7 +1462,7 @@ class PortableContact
|
|||
return;
|
||||
}
|
||||
|
||||
$gserver = DBA::selectFirst('gserver', ['id', 'relay-subscribe', 'relay-scope'], ['nurl' => normalise_link($server_url)]);
|
||||
$gserver = DBA::selectFirst('gserver', ['id', 'relay-subscribe', 'relay-scope'], ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
|
||||
if (!DBA::isResult($gserver)) {
|
||||
return;
|
||||
|
@ -1560,7 +1561,7 @@ class PortableContact
|
|||
foreach ($serverlist as $server) {
|
||||
$server_url = str_replace("/index.php", "", $server['url']);
|
||||
|
||||
$r = q("SELECT `nurl` FROM `gserver` WHERE `nurl` = '%s'", DBA::escape(normalise_link($server_url)));
|
||||
$r = q("SELECT `nurl` FROM `gserver` WHERE `nurl` = '%s'", DBA::escape(Strings::normaliseLink($server_url)));
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
Logger::log("Call server check for server ".$server_url, Logger::DEBUG);
|
||||
|
|
|
@ -52,7 +52,7 @@ class Salmon
|
|||
} else {
|
||||
$ret[$x] = substr($ret[$x], 5);
|
||||
}
|
||||
} elseif (normalise_link($ret[$x]) == 'http://') {
|
||||
} elseif (Strings::normaliseLink($ret[$x]) == 'http://') {
|
||||
$ret[$x] = Network::fetchUrl($ret[$x]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue