mirror of
https://github.com/friendica/friendica
synced 2025-04-29 10:24:23 +02:00
Stopped using deprecated constants NETWORK_* (#5537)
* Rewrite: - stopped using deprecated NETWORK_* constants, now Protocol::* should be used - still left them intact for slow/lazy developers ... * Removed deprecated NETWORK_* constants as per code reviewer's request.
This commit is contained in:
parent
c623465df2
commit
e06fc2aa69
59 changed files with 527 additions and 492 deletions
|
@ -17,6 +17,7 @@ use Friendica\Content\Text\HTML;
|
|||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -272,7 +273,7 @@ class DFRN
|
|||
|
||||
foreach ($items as $item) {
|
||||
// prevent private email from leaking.
|
||||
if ($item['network'] == NETWORK_MAIL) {
|
||||
if ($item['network'] == Protocol::MAIL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1533,7 +1534,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"]), NETWORK_STATUSNET];
|
||||
$importer["importer_uid"], normalise_link($author["link"]), Protocol::STATUSNET];
|
||||
$contact_old = DBA::selectFirst('contact', $fields, $condition);
|
||||
|
||||
if (DBA::isResult($contact_old)) {
|
||||
|
@ -2822,7 +2823,7 @@ class DFRN
|
|||
|
||||
$header = [];
|
||||
$header["uid"] = $importer["importer_uid"];
|
||||
$header["network"] = NETWORK_DFRN;
|
||||
$header["network"] = Protocol::DFRN;
|
||||
$header["wall"] = 0;
|
||||
$header["origin"] = 0;
|
||||
$header["contact-id"] = $importer["id"];
|
||||
|
@ -2956,7 +2957,7 @@ class DFRN
|
|||
$r = q("SELECT * FROM contact WHERE nick = '%s'
|
||||
AND network = '%s' AND uid = %d AND url LIKE '%%%s%%' LIMIT 1",
|
||||
DBA::escape($contact_nick),
|
||||
DBA::escape(NETWORK_DFRN),
|
||||
DBA::escape(Protocol::DFRN),
|
||||
intval(local_user()),
|
||||
DBA::escape($baseurl)
|
||||
);
|
||||
|
|
|
@ -16,6 +16,7 @@ use Friendica\Core\Cache;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -176,7 +177,7 @@ class Diaspora
|
|||
{
|
||||
$fields = ['created' => DateTimeFormat::utcNow(),
|
||||
'name' => 'relay', 'nick' => 'relay',
|
||||
'url' => $server_url, 'network' => NETWORK_DIASPORA,
|
||||
'url' => $server_url, 'network' => Protocol::DIASPORA,
|
||||
'batch' => $server_url . '/receive/public',
|
||||
'rel' => Contact::FOLLOWER, 'blocked' => false,
|
||||
'pending' => false, 'writable' => true];
|
||||
|
@ -899,7 +900,7 @@ class Diaspora
|
|||
{
|
||||
$update = false;
|
||||
|
||||
$person = DBA::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
|
||||
$person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]);
|
||||
if (DBA::isResult($person)) {
|
||||
logger("In cache " . print_r($person, true), LOGGER_DEBUG);
|
||||
|
||||
|
@ -916,15 +917,15 @@ class Diaspora
|
|||
|
||||
if (!DBA::isResult($person) || $update) {
|
||||
logger("create or refresh", LOGGER_DEBUG);
|
||||
$r = Probe::uri($handle, NETWORK_DIASPORA);
|
||||
$r = Probe::uri($handle, Protocol::DIASPORA);
|
||||
|
||||
// Note that Friendica contacts will return a "Diaspora person"
|
||||
// if Diaspora connectivity is enabled on their server
|
||||
if ($r && ($r["network"] === NETWORK_DIASPORA)) {
|
||||
if ($r && ($r["network"] === Protocol::DIASPORA)) {
|
||||
self::updateFContact($r);
|
||||
|
||||
// Fetch the updated or added contact
|
||||
$person = DBA::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
|
||||
$person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]);
|
||||
if (!DBA::isResult($person)) {
|
||||
$person = $r;
|
||||
}
|
||||
|
@ -1017,7 +1018,7 @@ class Diaspora
|
|||
|
||||
$r = q(
|
||||
"SELECT `url` FROM `fcontact` WHERE `url` != '' AND `network` = '%s' AND `guid` = '%s'",
|
||||
DBA::escape(NETWORK_DIASPORA),
|
||||
DBA::escape(Protocol::DIASPORA),
|
||||
DBA::escape($fcontact_guid)
|
||||
);
|
||||
|
||||
|
@ -1419,7 +1420,7 @@ class Diaspora
|
|||
$network = $contact["network"];
|
||||
} else {
|
||||
$cid = $def_contact["id"];
|
||||
$network = NETWORK_DIASPORA;
|
||||
$network = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
return ["cid" => $cid, "network" => $network];
|
||||
|
@ -1459,7 +1460,7 @@ class Diaspora
|
|||
}
|
||||
}
|
||||
|
||||
if ($contact["network"] == NETWORK_DFRN) {
|
||||
if ($contact["network"] == Protocol::DFRN) {
|
||||
return str_replace("/profile/" . $contact["nick"] . "/", "/display/" . $guid, $contact["url"] . "/");
|
||||
}
|
||||
|
||||
|
@ -1509,7 +1510,7 @@ class Diaspora
|
|||
|
||||
// change the technical stuff in contact and gcontact
|
||||
$data = Probe::uri($new_handle);
|
||||
if ($data['network'] == NETWORK_PHANTOM) {
|
||||
if ($data['network'] == Protocol::PHANTOM) {
|
||||
logger('Account for '.$new_handle." couldn't be probed.");
|
||||
return false;
|
||||
}
|
||||
|
@ -2281,7 +2282,7 @@ class Diaspora
|
|||
|
||||
DBA::update('contact', $fields, ['id' => $contact['id']]);
|
||||
|
||||
$gcontact = ["url" => $contact["url"], "network" => NETWORK_DIASPORA, "generation" => 2,
|
||||
$gcontact = ["url" => $contact["url"], "network" => Protocol::DIASPORA, "generation" => 2,
|
||||
"photo" => $image_url, "name" => $name, "location" => $location,
|
||||
"about" => $about, "birthday" => $birthday, "gender" => $gender,
|
||||
"addr" => $author, "nick" => $nick, "keywords" => $keywords,
|
||||
|
@ -2392,7 +2393,7 @@ class Diaspora
|
|||
|
||||
$ret = self::personByHandle($author);
|
||||
|
||||
if (!$ret || ($ret["network"] != NETWORK_DIASPORA)) {
|
||||
if (!$ret || ($ret["network"] != Protocol::DIASPORA)) {
|
||||
logger("Cannot resolve diaspora handle ".$author." for ".$recipient);
|
||||
return false;
|
||||
}
|
||||
|
@ -2617,7 +2618,7 @@ class Diaspora
|
|||
|
||||
$datarray["uid"] = $importer["uid"];
|
||||
$datarray["contact-id"] = $contact["id"];
|
||||
$datarray["network"] = NETWORK_DIASPORA;
|
||||
$datarray["network"] = Protocol::DIASPORA;
|
||||
|
||||
$datarray["author-link"] = $contact["url"];
|
||||
$datarray["author-id"] = Contact::getIdForURL($contact["url"], 0);
|
||||
|
@ -2845,7 +2846,7 @@ class Diaspora
|
|||
|
||||
$datarray["uid"] = $importer["uid"];
|
||||
$datarray["contact-id"] = $contact["id"];
|
||||
$datarray["network"] = NETWORK_DIASPORA;
|
||||
$datarray["network"] = Protocol::DIASPORA;
|
||||
|
||||
$datarray["author-link"] = $contact["url"];
|
||||
$datarray["author-id"] = Contact::getIdForURL($contact["url"], 0);
|
||||
|
@ -3110,7 +3111,7 @@ class Diaspora
|
|||
if (!$no_queue && ($contact['contact-type'] != Contact::ACCOUNT_TYPE_RELAY)) {
|
||||
logger("queue message");
|
||||
// queue message for redelivery
|
||||
Queue::add($contact["id"], NETWORK_DIASPORA, $envelope, $public_batch, $guid);
|
||||
Queue::add($contact["id"], Protocol::DIASPORA, $envelope, $public_batch, $guid);
|
||||
}
|
||||
|
||||
// The message could not be delivered. We mark the contact as "dead"
|
||||
|
@ -3167,7 +3168,7 @@ class Diaspora
|
|||
$envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $contact['pubkey'], $public_batch);
|
||||
|
||||
if ($spool) {
|
||||
Queue::add($contact['id'], NETWORK_DIASPORA, $envelope, $public_batch, $guid);
|
||||
Queue::add($contact['id'], Protocol::DIASPORA, $envelope, $public_batch, $guid);
|
||||
return true;
|
||||
} else {
|
||||
$return_code = self::transmit($owner, $contact, $envelope, $public_batch, false, $guid);
|
||||
|
@ -3358,7 +3359,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
if (($guid != "") && $complete) {
|
||||
$condition = ['guid' => $guid, 'network' => [NETWORK_DFRN, NETWORK_DIASPORA]];
|
||||
$condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
||||
$item = Item::selectFirst(['contact-id'], $condition);
|
||||
if (DBA::isResult($item)) {
|
||||
$ret= [];
|
||||
|
@ -4133,7 +4134,7 @@ class Diaspora
|
|||
$recips = q(
|
||||
"SELECT `id`,`name`,`network`,`pubkey`,`notify` FROM `contact` WHERE `network` = '%s'
|
||||
AND `uid` = %d AND `rel` != %d",
|
||||
DBA::escape(NETWORK_DIASPORA),
|
||||
DBA::escape(Protocol::DIASPORA),
|
||||
intval($uid),
|
||||
intval(Contact::SHARING)
|
||||
);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
namespace Friendica\Protocol;
|
||||
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Protocol;
|
||||
|
||||
/**
|
||||
* @brief Email class
|
||||
|
@ -308,7 +309,7 @@ class Email
|
|||
}
|
||||
|
||||
/**
|
||||
* Function send is used by NETWORK_EMAIL and NETWORK_EMAIL2 code
|
||||
* Function send is used by Protocol::EMAIL and Protocol::EMAIL2 code
|
||||
* (not to notify the user, but to send items to email contacts)
|
||||
*
|
||||
* @param string $addr address
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace Friendica\Protocol;
|
|||
use DOMDocument;
|
||||
use DOMXPath;
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -187,7 +188,7 @@ class Feed {
|
|||
|
||||
$header = [];
|
||||
$header["uid"] = $importer["uid"];
|
||||
$header["network"] = NETWORK_FEED;
|
||||
$header["network"] = Protocol::FEED;
|
||||
$header["wall"] = 0;
|
||||
$header["origin"] = 0;
|
||||
$header["gravity"] = GRAVITY_PARENT;
|
||||
|
@ -244,7 +245,7 @@ class Feed {
|
|||
|
||||
if (!$simulate) {
|
||||
$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
|
||||
$importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
|
||||
$importer["uid"], $item["uri"], Protocol::FEED, Protocol::DFRN];
|
||||
$previous = Item::selectFirst(['id'], $condition);
|
||||
if (DBA::isResult($previous)) {
|
||||
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG);
|
||||
|
|
|
@ -12,6 +12,7 @@ use Friendica\Core\Cache;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Lock;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -75,7 +76,7 @@ class OStatus
|
|||
$contact = null;
|
||||
if ($aliaslink != '') {
|
||||
$condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
|
||||
$importer["uid"], $aliaslink, NETWORK_STATUSNET,
|
||||
$importer["uid"], $aliaslink, Protocol::STATUSNET,
|
||||
Contact::SHARING, Contact::FRIEND];
|
||||
$contact = DBA::selectFirst('contact', [], $condition);
|
||||
}
|
||||
|
@ -87,13 +88,13 @@ class OStatus
|
|||
|
||||
$condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ? AND `rel` IN (?, ?)",
|
||||
$importer["uid"], normalise_link($author["author-link"]), normalise_link($aliaslink),
|
||||
NETWORK_STATUSNET, Contact::SHARING, Contact::FRIEND];
|
||||
Protocol::STATUSNET, Contact::SHARING, Contact::FRIEND];
|
||||
$contact = DBA::selectFirst('contact', [], $condition);
|
||||
}
|
||||
|
||||
if (!DBA::isResult($contact) && ($addr != '')) {
|
||||
$condition = ["`uid` = ? AND `addr` = ? AND `network` != ? AND `rel` IN (?, ?)",
|
||||
$importer["uid"], $addr, NETWORK_STATUSNET,
|
||||
$importer["uid"], $addr, Protocol::STATUSNET,
|
||||
Contact::SHARING, Contact::FRIEND];
|
||||
$contact = DBA::selectFirst('contact', [], $condition);
|
||||
}
|
||||
|
@ -135,7 +136,7 @@ class OStatus
|
|||
$author["owner-id"] = $author["author-id"];
|
||||
|
||||
// Only update the contacts if it is an OStatus contact
|
||||
if (DBA::isResult($contact) && ($contact['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) {
|
||||
if (DBA::isResult($contact) && ($contact['id'] > 0) && !$onlyfetch && ($contact["network"] == Protocol::OSTATUS)) {
|
||||
|
||||
// Update contact data
|
||||
$current = $contact;
|
||||
|
@ -345,7 +346,7 @@ class OStatus
|
|||
|
||||
$header = [];
|
||||
$header["uid"] = $importer["uid"];
|
||||
$header["network"] = NETWORK_OSTATUS;
|
||||
$header["network"] = Protocol::OSTATUS;
|
||||
$header["wall"] = 0;
|
||||
$header["origin"] = 0;
|
||||
$header["gravity"] = GRAVITY_COMMENT;
|
||||
|
@ -799,7 +800,7 @@ class OStatus
|
|||
$conv_data = [];
|
||||
|
||||
$conv_data['protocol'] = Conversation::PARCEL_SPLIT_CONVERSATION;
|
||||
$conv_data['network'] = NETWORK_OSTATUS;
|
||||
$conv_data['network'] = Protocol::OSTATUS;
|
||||
$conv_data['uri'] = XML::getFirstNodeValue($xpath, 'atom:id/text()', $entry);
|
||||
|
||||
$inreplyto = $xpath->query('thr:in-reply-to', $entry);
|
||||
|
@ -1647,7 +1648,7 @@ class OStatus
|
|||
$title = self::entryHeader($doc, $entry, $owner, $item, $toplevel);
|
||||
|
||||
$condition = ['uid' => $owner["uid"], 'guid' => $repeated_guid, 'private' => false,
|
||||
'network' => [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]];
|
||||
'network' => [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]];
|
||||
$repeated_item = Item::selectFirst([], $condition);
|
||||
if (!DBA::isResult($repeated_item)) {
|
||||
return false;
|
||||
|
@ -1745,7 +1746,7 @@ class OStatus
|
|||
$object = $doc->createElement("activity:object");
|
||||
XML::addElement($doc, $object, "activity:object-type", ACTIVITY_OBJ_PERSON);
|
||||
|
||||
if ($contact['network'] == NETWORK_PHANTOM) {
|
||||
if ($contact['network'] == Protocol::PHANTOM) {
|
||||
XML::addElement($doc, $object, "id", $contact['url']);
|
||||
return $object;
|
||||
}
|
||||
|
@ -2161,7 +2162,7 @@ class OStatus
|
|||
|
||||
$condition = ["`uid` = ? AND `created` > ? AND NOT `deleted`
|
||||
AND NOT `private` AND `visible` AND `wall` AND `parent-network` IN (?, ?)",
|
||||
$owner["uid"], $check_date, NETWORK_OSTATUS, NETWORK_DFRN];
|
||||
$owner["uid"], $check_date, Protocol::OSTATUS, Protocol::DFRN];
|
||||
|
||||
if ($filter === 'comments') {
|
||||
$condition[0] .= " AND `object-type` = ? ";
|
||||
|
|
|
@ -14,6 +14,7 @@ use DOMXPath;
|
|||
use Exception;
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\GContact;
|
||||
|
@ -228,7 +229,7 @@ class PortableContact
|
|||
$friendica = preg_replace("=(https?://)(.*)/profile/(.*)=ism", "$1$2", $profile);
|
||||
if ($friendica != $profile) {
|
||||
$server_url = $friendica;
|
||||
$network = NETWORK_DFRN;
|
||||
$network = Protocol::DFRN;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,7 +237,7 @@ class PortableContact
|
|||
$diaspora = preg_replace("=(https?://)(.*)/u/(.*)=ism", "$1$2", $profile);
|
||||
if ($diaspora != $profile) {
|
||||
$server_url = $diaspora;
|
||||
$network = NETWORK_DIASPORA;
|
||||
$network = Protocol::DIASPORA;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,7 +245,7 @@ class PortableContact
|
|||
$red = preg_replace("=(https?://)(.*)/channel/(.*)=ism", "$1$2", $profile);
|
||||
if ($red != $profile) {
|
||||
$server_url = $red;
|
||||
$network = NETWORK_DIASPORA;
|
||||
$network = Protocol::DIASPORA;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +254,7 @@ class PortableContact
|
|||
$mastodon = preg_replace("=(https?://)(.*)/users/(.*)=ism", "$1$2", $profile);
|
||||
if ($mastodon != $profile) {
|
||||
$server_url = $mastodon;
|
||||
$network = NETWORK_OSTATUS;
|
||||
$network = Protocol::OSTATUS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,7 +263,7 @@ class PortableContact
|
|||
$ostatus = preg_replace("=(https?://)(.*)/user/(.*)=ism", "$1$2", $profile);
|
||||
if ($ostatus != $profile) {
|
||||
$server_url = $ostatus;
|
||||
$network = NETWORK_OSTATUS;
|
||||
$network = Protocol::OSTATUS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,7 +272,7 @@ class PortableContact
|
|||
$base = preg_replace("=(https?://)(.*?)/(.*)=ism", "$1$2", $profile);
|
||||
if ($base != $profile) {
|
||||
$server_url = $base;
|
||||
$network = NETWORK_PHANTOM;
|
||||
$network = Protocol::PHANTOM;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -332,7 +333,7 @@ class PortableContact
|
|||
$server_url = normalise_link(self::detectServer($profile));
|
||||
}
|
||||
|
||||
if (!in_array($gcontacts[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_FEED, NETWORK_OSTATUS, ""])) {
|
||||
if (!in_array($gcontacts[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) {
|
||||
logger("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
@ -350,7 +351,7 @@ class PortableContact
|
|||
$contact['server_url'] = $server_url;
|
||||
}
|
||||
|
||||
if (in_array($gcontacts[0]["network"], ["", NETWORK_FEED])) {
|
||||
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))
|
||||
|
@ -445,7 +446,7 @@ 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"] == NETWORK_OSTATUS) && self::alternateOStatusUrl($profile)
|
||||
if (($data["network"] == Protocol::OSTATUS) && self::alternateOStatusUrl($profile)
|
||||
&& (normalise_link($profile) == normalise_link($data["alias"]))
|
||||
&& (normalise_link($profile) != normalise_link($data["url"]))
|
||||
) {
|
||||
|
@ -469,7 +470,7 @@ class PortableContact
|
|||
return false;
|
||||
}
|
||||
|
||||
if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
|
||||
if (($data["poll"] == "") || (in_array($data["network"], [Protocol::FEED, Protocol::PHANTOM]))) {
|
||||
$fields = ['last_failure' => DateTimeFormat::utcNow()];
|
||||
DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
|
||||
|
@ -629,7 +630,7 @@ class PortableContact
|
|||
if ($url['type'] == 'zot') {
|
||||
$server = [];
|
||||
$server["platform"] = 'Hubzilla';
|
||||
$server["network"] = NETWORK_DIASPORA;
|
||||
$server["network"] = Protocol::DIASPORA;
|
||||
return $server;
|
||||
}
|
||||
}
|
||||
|
@ -757,13 +758,13 @@ class PortableContact
|
|||
}
|
||||
|
||||
if ($gnusocial) {
|
||||
$server['network'] = NETWORK_OSTATUS;
|
||||
$server['network'] = Protocol::OSTATUS;
|
||||
}
|
||||
if ($diaspora) {
|
||||
$server['network'] = NETWORK_DIASPORA;
|
||||
$server['network'] = Protocol::DIASPORA;
|
||||
}
|
||||
if ($friendica) {
|
||||
$server['network'] = NETWORK_DFRN;
|
||||
$server['network'] = Protocol::DFRN;
|
||||
}
|
||||
|
||||
if (!$server) {
|
||||
|
@ -838,11 +839,11 @@ class PortableContact
|
|||
}
|
||||
|
||||
if ($gnusocial) {
|
||||
$server['network'] = NETWORK_OSTATUS;
|
||||
$server['network'] = Protocol::OSTATUS;
|
||||
} elseif ($diaspora) {
|
||||
$server['network'] = NETWORK_DIASPORA;
|
||||
$server['network'] = Protocol::DIASPORA;
|
||||
} elseif ($friendica) {
|
||||
$server['network'] = NETWORK_DFRN;
|
||||
$server['network'] = Protocol::DFRN;
|
||||
}
|
||||
|
||||
if (empty($server)) {
|
||||
|
@ -883,7 +884,7 @@ class PortableContact
|
|||
$server = [];
|
||||
$server["platform"] = $version_part[0];
|
||||
$server["version"] = $version_part[1];
|
||||
$server["network"] = NETWORK_DFRN;
|
||||
$server["network"] = Protocol::DFRN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -903,7 +904,7 @@ class PortableContact
|
|||
$server = [];
|
||||
$server["platform"] = $attr['content'];
|
||||
$server["version"] = "";
|
||||
$server["network"] = NETWORK_DIASPORA;
|
||||
$server["network"] = Protocol::DIASPORA;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1106,14 +1107,14 @@ class PortableContact
|
|||
$platform = "Diaspora";
|
||||
$version = trim(str_replace("X-Diaspora-Version:", "", $line));
|
||||
$version = trim(str_replace("x-diaspora-version:", "", $version));
|
||||
$network = NETWORK_DIASPORA;
|
||||
$network = Protocol::DIASPORA;
|
||||
$versionparts = explode("-", $version);
|
||||
$version = $versionparts[0];
|
||||
}
|
||||
|
||||
if (stristr($line, 'Server: Mastodon')) {
|
||||
$platform = "Mastodon";
|
||||
$network = NETWORK_OSTATUS;
|
||||
$network = Protocol::OSTATUS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1132,7 +1133,7 @@ class PortableContact
|
|||
// Remove junk that some GNU Social servers return
|
||||
$version = str_replace(chr(239).chr(187).chr(191), "", $serverret["body"]);
|
||||
$version = trim($version, '"');
|
||||
$network = NETWORK_OSTATUS;
|
||||
$network = Protocol::OSTATUS;
|
||||
}
|
||||
|
||||
// Test for GNU Social
|
||||
|
@ -1144,7 +1145,7 @@ class PortableContact
|
|||
// Remove junk that some GNU Social servers return
|
||||
$version = str_replace(chr(239) . chr(187) . chr(191), "", $serverret["body"]);
|
||||
$version = trim($version, '"');
|
||||
$network = NETWORK_OSTATUS;
|
||||
$network = Protocol::OSTATUS;
|
||||
}
|
||||
|
||||
// Test for Mastodon
|
||||
|
@ -1159,7 +1160,7 @@ class PortableContact
|
|||
$version = $data['version'];
|
||||
$site_name = $data['title'];
|
||||
$info = $data['description'];
|
||||
$network = NETWORK_OSTATUS;
|
||||
$network = Protocol::OSTATUS;
|
||||
}
|
||||
|
||||
if (!empty($data['stats']['user_count'])) {
|
||||
|
@ -1183,7 +1184,7 @@ class PortableContact
|
|||
if (isset($data['url'])) {
|
||||
$platform = $data['platform'];
|
||||
$version = $data['version'];
|
||||
$network = NETWORK_DIASPORA;
|
||||
$network = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
if (!empty($data['site_name'])) {
|
||||
|
@ -1221,19 +1222,19 @@ class PortableContact
|
|||
if (isset($data['site']['platform'])) {
|
||||
$platform = $data['site']['platform']['PLATFORM_NAME'];
|
||||
$version = $data['site']['platform']['STD_VERSION'];
|
||||
$network = NETWORK_DIASPORA;
|
||||
$network = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
if (isset($data['site']['BlaBlaNet'])) {
|
||||
$platform = $data['site']['BlaBlaNet']['PLATFORM_NAME'];
|
||||
$version = $data['site']['BlaBlaNet']['STD_VERSION'];
|
||||
$network = NETWORK_DIASPORA;
|
||||
$network = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
if (isset($data['site']['hubzilla'])) {
|
||||
$platform = $data['site']['hubzilla']['PLATFORM_NAME'];
|
||||
$version = $data['site']['hubzilla']['RED_VERSION'];
|
||||
$network = NETWORK_DIASPORA;
|
||||
$network = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
if (isset($data['site']['redmatrix'])) {
|
||||
|
@ -1244,13 +1245,13 @@ class PortableContact
|
|||
}
|
||||
|
||||
$version = $data['site']['redmatrix']['RED_VERSION'];
|
||||
$network = NETWORK_DIASPORA;
|
||||
$network = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
if (isset($data['site']['friendica'])) {
|
||||
$platform = $data['site']['friendica']['FRIENDICA_PLATFORM'];
|
||||
$version = $data['site']['friendica']['FRIENDICA_VERSION'];
|
||||
$network = NETWORK_DFRN;
|
||||
$network = Protocol::DFRN;
|
||||
}
|
||||
|
||||
$site_name = $data['site']['name'];
|
||||
|
@ -1306,7 +1307,7 @@ class PortableContact
|
|||
}
|
||||
|
||||
if ($platform == "Diaspora") {
|
||||
$network = NETWORK_DIASPORA;
|
||||
$network = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
if (!empty($data['registrations_open']) && $data['registrations_open']) {
|
||||
|
@ -1348,7 +1349,7 @@ class PortableContact
|
|||
|
||||
// Check for noscrape
|
||||
// Friendica servers could be detected as OStatus servers
|
||||
if (!$failure && in_array($network, [NETWORK_DFRN, NETWORK_OSTATUS])) {
|
||||
if (!$failure && in_array($network, [Protocol::DFRN, Protocol::OSTATUS])) {
|
||||
$serverret = Network::curl($server_url . "/friendica/json");
|
||||
|
||||
if (!$serverret["success"]) {
|
||||
|
@ -1359,7 +1360,7 @@ class PortableContact
|
|||
$data = json_decode($serverret["body"], true);
|
||||
|
||||
if (isset($data['version'])) {
|
||||
$network = NETWORK_DFRN;
|
||||
$network = Protocol::DFRN;
|
||||
|
||||
if (!empty($data['no_scrape_url'])) {
|
||||
$noscrape = $data['no_scrape_url'];
|
||||
|
@ -1423,7 +1424,7 @@ class PortableContact
|
|||
DBA::insert('gserver', $fields);
|
||||
}
|
||||
|
||||
if (!$failure && in_array($fields['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
|
||||
if (!$failure && in_array($fields['network'], [Protocol::DFRN, Protocol::DIASPORA])) {
|
||||
self::discoverRelay($server_url);
|
||||
}
|
||||
|
||||
|
@ -1485,7 +1486,7 @@ class PortableContact
|
|||
$fields = [];
|
||||
if (isset($data['protocols'])) {
|
||||
if (isset($data['protocols']['diaspora'])) {
|
||||
$fields['network'] = NETWORK_DIASPORA;
|
||||
$fields['network'] = Protocol::DIASPORA;
|
||||
|
||||
if (isset($data['protocols']['diaspora']['receive'])) {
|
||||
$fields['batch'] = $data['protocols']['diaspora']['receive'];
|
||||
|
@ -1495,7 +1496,7 @@ class PortableContact
|
|||
}
|
||||
|
||||
if (isset($data['protocols']['dfrn'])) {
|
||||
$fields['network'] = NETWORK_DFRN;
|
||||
$fields['network'] = Protocol::DFRN;
|
||||
|
||||
if (isset($data['protocols']['dfrn']['receive'])) {
|
||||
$fields['batch'] = $data['protocols']['dfrn']['receive'];
|
||||
|
@ -1518,9 +1519,9 @@ class PortableContact
|
|||
WHERE `network` IN ('%s', '%s', '%s') AND `last_contact` > `last_failure`
|
||||
ORDER BY `last_contact`
|
||||
LIMIT 1000",
|
||||
DBA::escape(NETWORK_DFRN),
|
||||
DBA::escape(NETWORK_DIASPORA),
|
||||
DBA::escape(NETWORK_OSTATUS)
|
||||
DBA::escape(Protocol::DFRN),
|
||||
DBA::escape(Protocol::DIASPORA),
|
||||
DBA::escape(Protocol::OSTATUS)
|
||||
);
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue