use Friendica\Util\Strings;
use Friendica\Util\XML;
-require_once 'include/dba.php';
-
class PortableContact
{
/**
* Once the global contact is stored add (if necessary) the contact linkage which associates
* the given uid, cid to the global contact entry. There can be many uid/cid combinations
* pointing to the same global contact id.
- *
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function loadWorker($cid, $uid = 0, $zcid = 0, $url = null)
{
* @param integer $uid User ID
* @param integer $zcid Global Contact ID
* @param integer $url POCO address that should be polled
- *
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function load($cid, $uid, $zcid, $url)
{
- $a = get_app();
-
if ($cid) {
if (!$url || !$uid) {
$contact = DBA::selectFirst('contact', ['poco', 'uid'], ['id' => $cid]);
$friendica = preg_replace("=(https?://)(.*)/profile/(.*)=ism", "$1$2", $profile);
if ($friendica != $profile) {
$server_url = $friendica;
- $network = Protocol::DFRN;
}
}
$diaspora = preg_replace("=(https?://)(.*)/u/(.*)=ism", "$1$2", $profile);
if ($diaspora != $profile) {
$server_url = $diaspora;
- $network = Protocol::DIASPORA;
}
}
$red = preg_replace("=(https?://)(.*)/channel/(.*)=ism", "$1$2", $profile);
if ($red != $profile) {
$server_url = $red;
- $network = Protocol::DIASPORA;
}
}
$mastodon = preg_replace("=(https?://)(.*)/users/(.*)=ism", "$1$2", $profile);
if ($mastodon != $profile) {
$server_url = $mastodon;
- $network = Protocol::OSTATUS;
}
}
$ostatus = preg_replace("=(https?://)(.*)/user/(.*)=ism", "$1$2", $profile);
if ($ostatus != $profile) {
$server_url = $ostatus;
- $network = Protocol::OSTATUS;
}
}
$base = preg_replace("=(https?://)(.*?)/(.*)=ism", "$1$2", $profile);
if ($base != $profile) {
$server_url = $base;
- $network = Protocol::PHANTOM;
}
}
$server_url = Strings::normaliseLink(self::detectServer($profile));
}
- if (!in_array($gcontacts[0]["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) {
+ if (!in_array($gcontacts[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) {
Logger::log("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", Logger::DEBUG);
return false;
}
*/
private static function detectPocoData(array $data)
{
- $server = false;
-
if (!isset($data['entry'])) {
return false;
}
*
* @param string $server_url address of the server
* @return array Server data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function fetchNodeinfo($server_url)
{
*
* @param string $nodeinfo_url address of the nodeinfo path
* @return array Server data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function parseNodeinfo1($nodeinfo_url)
{
}
}
- if (!empty($nodeinfo['metadata']) && isset($nodeinfo['metadata']['nodeName'])) {
+ if (isset($nodeinfo['metadata']['nodeName'])) {
$server['site_name'] = $nodeinfo['metadata']['nodeName'];
}
*
* @param string $nodeinfo_url address of the nodeinfo path
* @return array Server data
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function parseNodeinfo2($nodeinfo_url)
{
}
}
- if (!empty($nodeinfo['metadata']) && isset($nodeinfo['metadata']['nodeName'])) {
+ if (isset($nodeinfo['metadata']['nodeName'])) {
$server['site_name'] = $nodeinfo['metadata']['nodeName'];
}
$site_name = $data['site_name'];
}
- $info = $data['info'];
+ $info = defaults($data, 'info', '');
$register_policy = defaults($data, 'register_policy', REGISTER_CLOSED);
if (in_array($register_policy, ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'])) {
- $register_policy = constant($data['register_policy']);
+ $register_policy = constant($register_policy);
} else {
Logger::log("Register policy '$register_policy' from $server_url is invalid.");
$register_policy = REGISTER_CLOSED; // set a default value
}
- $platform = $data['platform'];
+ $platform = defaults($data, 'platform', '');
}
}
}
* @brief Fetch relay data from a given server url
*
* @param string $server_url address of the server
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function discoverRelay($server_url)
{
/**
* @brief Returns a list of all known servers
* @return array List of server urls
+ * @throws Exception
*/
public static function serverlist()
{
* @brief Fetch server list from remote servers and adds them when they are new.
*
* @param string $poco URL to the POCO endpoint
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function fetchServerlist($poco)
{
$curlResult = Network::curl($url);
if ($curlResult->isSuccess()) {
- $data = json_decode($curlResult["body"], true);
+ $data = json_decode($curlResult->getBody(), true);
if (!empty($data)) {
self::discoverServer($data, 3);