mirror of
https://github.com/friendica/friendica
synced 2025-04-26 09:10:15 +00: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
|
@ -9,6 +9,7 @@ use Friendica\Core\Addon;
|
|||
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;
|
||||
|
@ -146,7 +147,7 @@ class Contact extends BaseObject
|
|||
AND `contact`.`notify` != ""',
|
||||
$gid,
|
||||
local_user(),
|
||||
NETWORK_OSTATUS
|
||||
Protocol::OSTATUS
|
||||
);
|
||||
$return = $contacts['count'];
|
||||
}
|
||||
|
@ -334,7 +335,7 @@ class Contact extends BaseObject
|
|||
*/
|
||||
public static function terminateFriendship(array $user, array $contact)
|
||||
{
|
||||
if (in_array($contact['network'], [NETWORK_OSTATUS, NETWORK_DFRN])) {
|
||||
if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) {
|
||||
// create an unfollow slap
|
||||
$item = [];
|
||||
$item['verb'] = NAMESPACE_OSTATUS . "/unfollow";
|
||||
|
@ -349,7 +350,7 @@ class Contact extends BaseObject
|
|||
if (!empty($contact['notify'])) {
|
||||
Salmon::slapper($user, $contact['notify'], $slap);
|
||||
}
|
||||
} elseif ($contact['network'] == NETWORK_DIASPORA) {
|
||||
} elseif ($contact['network'] == Protocol::DIASPORA) {
|
||||
Diaspora::sendUnshare($user, $contact);
|
||||
}
|
||||
}
|
||||
|
@ -508,7 +509,7 @@ class Contact extends BaseObject
|
|||
// If there is more than one entry we filter out the connector networks
|
||||
if (count($r) > 1) {
|
||||
foreach ($r as $id => $result) {
|
||||
if ($result["network"] == NETWORK_STATUSNET) {
|
||||
if ($result["network"] == Protocol::STATUSNET) {
|
||||
unset($r[$id]);
|
||||
}
|
||||
}
|
||||
|
@ -562,13 +563,13 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
if ((empty($profile["addr"]) || empty($profile["name"])) && (defaults($profile, "gid", 0) != 0)
|
||||
&& in_array($profile["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])
|
||||
&& in_array($profile["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])
|
||||
) {
|
||||
Worker::add(PRIORITY_LOW, "UpdateGContact", $profile["gid"]);
|
||||
}
|
||||
|
||||
// Show contact details of Diaspora contacts only if connected
|
||||
if ((defaults($profile, "cid", 0) == 0) && (defaults($profile, "network", "") == NETWORK_DIASPORA)) {
|
||||
if ((defaults($profile, "cid", 0) == 0) && (defaults($profile, "network", "") == Protocol::DIASPORA)) {
|
||||
$profile["location"] = "";
|
||||
$profile["about"] = "";
|
||||
$profile["gender"] = "";
|
||||
|
@ -687,7 +688,7 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
$sparkle = false;
|
||||
if (($contact['network'] === NETWORK_DFRN) && !$contact['self']) {
|
||||
if (($contact['network'] === Protocol::DFRN) && !$contact['self']) {
|
||||
$sparkle = true;
|
||||
$profile_link = System::baseUrl() . '/redir/' . $contact['id'];
|
||||
} else {
|
||||
|
@ -704,11 +705,11 @@ class Contact extends BaseObject
|
|||
$profile_link = $profile_link . '?url=profile';
|
||||
}
|
||||
|
||||
if (in_array($contact['network'], [NETWORK_DFRN, NETWORK_DIASPORA]) && !$contact['self']) {
|
||||
if (in_array($contact['network'], [Protocol::DFRN, Protocol::DIASPORA]) && !$contact['self']) {
|
||||
$pm_url = System::baseUrl() . '/message/new/' . $contact['id'];
|
||||
}
|
||||
|
||||
if (($contact['network'] == NETWORK_DFRN) && !$contact['self']) {
|
||||
if (($contact['network'] == Protocol::DFRN) && !$contact['self']) {
|
||||
$poke_link = System::baseUrl() . '/poke/?f=&c=' . $contact['id'];
|
||||
}
|
||||
|
||||
|
@ -869,7 +870,7 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
// Last try in gcontact for unsupported networks
|
||||
if (!in_array($data["network"], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_PUMPIO, NETWORK_MAIL, NETWORK_FEED])) {
|
||||
if (!in_array($data["network"], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::PUMPIO, Protocol::MAIL, Protocol::FEED])) {
|
||||
if ($uid != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -1108,7 +1109,7 @@ class Contact extends BaseObject
|
|||
return '';
|
||||
}
|
||||
|
||||
if (in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
|
||||
if (in_array($r[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
|
||||
$sql = "(`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))";
|
||||
} else {
|
||||
$sql = "`item`.`uid` = ?";
|
||||
|
@ -1400,7 +1401,7 @@ class Contact extends BaseObject
|
|||
);
|
||||
}
|
||||
|
||||
if (($ret['network'] === NETWORK_DFRN) && !DBA::isResult($r)) {
|
||||
if (($ret['network'] === Protocol::DFRN) && !DBA::isResult($r)) {
|
||||
if ($interactive) {
|
||||
if (strlen($a->urlpath)) {
|
||||
$myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']);
|
||||
|
@ -1412,14 +1413,14 @@ class Contact extends BaseObject
|
|||
|
||||
// NOTREACHED
|
||||
}
|
||||
} elseif (Config::get('system', 'dfrn_only') && ($ret['network'] != NETWORK_DFRN)) {
|
||||
} elseif (Config::get('system', 'dfrn_only') && ($ret['network'] != Protocol::DFRN)) {
|
||||
$result['message'] = L10n::t('This site is not configured to allow communications with other networks.') . EOL;
|
||||
$result['message'] != L10n::t('No compatible communication protocols or feeds were discovered.') . EOL;
|
||||
return $result;
|
||||
}
|
||||
|
||||
// This extra param just confuses things, remove it
|
||||
if ($ret['network'] === NETWORK_DIASPORA) {
|
||||
if ($ret['network'] === Protocol::DIASPORA) {
|
||||
$ret['url'] = str_replace('?absolute=true', '', $ret['url']);
|
||||
}
|
||||
|
||||
|
@ -1443,7 +1444,7 @@ class Contact extends BaseObject
|
|||
return $result;
|
||||
}
|
||||
|
||||
if ($ret['network'] === NETWORK_OSTATUS && Config::get('system', 'ostatus_disabled')) {
|
||||
if ($ret['network'] === Protocol::OSTATUS && Config::get('system', 'ostatus_disabled')) {
|
||||
$result['message'] .= L10n::t('The profile address specified belongs to a network which has been disabled on this site.') . EOL;
|
||||
$ret['notify'] = '';
|
||||
}
|
||||
|
@ -1452,13 +1453,13 @@ class Contact extends BaseObject
|
|||
$result['message'] .= L10n::t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL;
|
||||
}
|
||||
|
||||
$writeable = ((($ret['network'] === NETWORK_OSTATUS) && ($ret['notify'])) ? 1 : 0);
|
||||
$writeable = ((($ret['network'] === Protocol::OSTATUS) && ($ret['notify'])) ? 1 : 0);
|
||||
|
||||
$subhub = (($ret['network'] === NETWORK_OSTATUS) ? true : false);
|
||||
$subhub = (($ret['network'] === Protocol::OSTATUS) ? true : false);
|
||||
|
||||
$hidden = (($ret['network'] === NETWORK_MAIL) ? 1 : 0);
|
||||
$hidden = (($ret['network'] === Protocol::MAIL) ? 1 : 0);
|
||||
|
||||
if (in_array($ret['network'], [NETWORK_MAIL, NETWORK_DIASPORA])) {
|
||||
if (in_array($ret['network'], [Protocol::MAIL, Protocol::DIASPORA])) {
|
||||
$writeable = 1;
|
||||
}
|
||||
|
||||
|
@ -1469,7 +1470,7 @@ class Contact extends BaseObject
|
|||
$fields = ['rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false];
|
||||
DBA::update('contact', $fields, ['id' => $r[0]['id']]);
|
||||
} else {
|
||||
$new_relation = ((in_array($ret['network'], [NETWORK_MAIL])) ? self::FRIEND : self::SHARING);
|
||||
$new_relation = ((in_array($ret['network'], [Protocol::MAIL])) ? self::FRIEND : self::SHARING);
|
||||
|
||||
// create contact record
|
||||
DBA::insert('contact', [
|
||||
|
@ -1522,7 +1523,7 @@ class Contact extends BaseObject
|
|||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
if (in_array($contact['network'], [NETWORK_OSTATUS, NETWORK_DFRN])) {
|
||||
if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) {
|
||||
// create a follow slap
|
||||
$item = [];
|
||||
$item['verb'] = ACTIVITY_FOLLOW;
|
||||
|
@ -1536,7 +1537,7 @@ class Contact extends BaseObject
|
|||
if (!empty($contact['notify'])) {
|
||||
Salmon::slapper($r[0], $contact['notify'], $slap);
|
||||
}
|
||||
} elseif ($contact['network'] == NETWORK_DIASPORA) {
|
||||
} elseif ($contact['network'] == Protocol::DIASPORA) {
|
||||
$ret = Diaspora::sendShare($a->user, $contact);
|
||||
logger('share returns: ' . $ret);
|
||||
}
|
||||
|
@ -1817,7 +1818,7 @@ class Contact extends BaseObject
|
|||
*/
|
||||
public static function magicLinkbyContact($contact, $url = '')
|
||||
{
|
||||
if ($contact['network'] != NETWORK_DFRN) {
|
||||
if ($contact['network'] != Protocol::DFRN) {
|
||||
return $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
|
@ -32,8 +33,8 @@ class Conversation
|
|||
*/
|
||||
public static function insert(array $arr)
|
||||
{
|
||||
if (in_array(defaults($arr, 'network', NETWORK_PHANTOM),
|
||||
[NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_TWITTER]) && !empty($arr['uri'])) {
|
||||
if (in_array(defaults($arr, 'network', Protocol::PHANTOM),
|
||||
[Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::TWITTER]) && !empty($arr['uri'])) {
|
||||
$conversation = ['item-uri' => $arr['uri'], 'received' => DateTimeFormat::utcNow()];
|
||||
|
||||
if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) {
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Friendica\Model;
|
|||
|
||||
use Exception;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -39,15 +40,15 @@ class GContact
|
|||
|
||||
// check supported networks
|
||||
if (Config::get('system', 'diaspora_enabled')) {
|
||||
$diaspora = NETWORK_DIASPORA;
|
||||
$diaspora = Protocol::DIASPORA;
|
||||
} else {
|
||||
$diaspora = NETWORK_DFRN;
|
||||
$diaspora = Protocol::DFRN;
|
||||
}
|
||||
|
||||
if (!Config::get('system', 'ostatus_disabled')) {
|
||||
$ostatus = NETWORK_OSTATUS;
|
||||
$ostatus = Protocol::OSTATUS;
|
||||
} else {
|
||||
$ostatus = NETWORK_DFRN;
|
||||
$ostatus = Protocol::DFRN;
|
||||
}
|
||||
|
||||
// check if we search only communities or every contact
|
||||
|
@ -64,7 +65,7 @@ class GContact
|
|||
((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
|
||||
(`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?) $extra_sql
|
||||
GROUP BY `nurl` ORDER BY `nurl` DESC LIMIT 1000",
|
||||
NETWORK_DFRN, $ostatus, $diaspora, $search, $search, $search
|
||||
Protocol::DFRN, $ostatus, $diaspora, $search, $search, $search
|
||||
);
|
||||
|
||||
$gcontacts = [];
|
||||
|
@ -156,13 +157,13 @@ class GContact
|
|||
}
|
||||
|
||||
// Don't store the statusnet connector as network
|
||||
// We can't simply set this to NETWORK_OSTATUS since the connector could have fetched posts from friendica as well
|
||||
if ($gcontact['network'] == NETWORK_STATUSNET) {
|
||||
// We can't simply set this to Protocol::OSTATUS since the connector could have fetched posts from friendica as well
|
||||
if ($gcontact['network'] == Protocol::STATUSNET) {
|
||||
$gcontact['network'] = "";
|
||||
}
|
||||
|
||||
// Assure that there are no parameter fragments in the profile url
|
||||
if (in_array($gcontact['network'], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
|
||||
if (in_array($gcontact['network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
|
||||
$gcontact['url'] = self::cleanContactUrl($gcontact['url']);
|
||||
}
|
||||
|
||||
|
@ -177,18 +178,18 @@ class GContact
|
|||
$r = q(
|
||||
"SELECT `network` FROM `contact` WHERE `uid` = 0 AND `nurl` = '%s' AND `network` != '' AND `network` != '%s' LIMIT 1",
|
||||
DBA::escape(normalise_link($gcontact['url'])),
|
||||
DBA::escape(NETWORK_STATUSNET)
|
||||
DBA::escape(Protocol::STATUSNET)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$gcontact['network'] = $r[0]["network"];
|
||||
}
|
||||
|
||||
if (($gcontact['network'] == "") || ($gcontact['network'] == NETWORK_OSTATUS)) {
|
||||
if (($gcontact['network'] == "") || ($gcontact['network'] == Protocol::OSTATUS)) {
|
||||
$r = q(
|
||||
"SELECT `network`, `url` FROM `contact` WHERE `uid` = 0 AND `alias` IN ('%s', '%s') AND `network` != '' AND `network` != '%s' LIMIT 1",
|
||||
DBA::escape($gcontact['url']),
|
||||
DBA::escape(normalise_link($gcontact['url'])),
|
||||
DBA::escape(NETWORK_STATUSNET)
|
||||
DBA::escape(Protocol::STATUSNET)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$gcontact['network'] = $r[0]["network"];
|
||||
|
@ -205,7 +206,7 @@ class GContact
|
|||
);
|
||||
|
||||
if (DBA::isResult($x)) {
|
||||
if (!isset($gcontact['network']) && ($x[0]["network"] != NETWORK_STATUSNET)) {
|
||||
if (!isset($gcontact['network']) && ($x[0]["network"] != Protocol::STATUSNET)) {
|
||||
$gcontact['network'] = $x[0]["network"];
|
||||
}
|
||||
if ($gcontact['updated'] <= NULL_DATE) {
|
||||
|
@ -224,7 +225,7 @@ class GContact
|
|||
) {
|
||||
$data = Probe::uri($gcontact['url']);
|
||||
|
||||
if ($data["network"] == NETWORK_PHANTOM) {
|
||||
if ($data["network"] == Protocol::PHANTOM) {
|
||||
throw new Exception('Probing for URL '.$gcontact['url'].' failed');
|
||||
}
|
||||
|
||||
|
@ -234,7 +235,7 @@ class GContact
|
|||
|
||||
$gcontact = array_merge($gcontact, $data);
|
||||
|
||||
if ($alternate && ($gcontact['network'] == NETWORK_OSTATUS)) {
|
||||
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)]);
|
||||
|
@ -246,7 +247,7 @@ class GContact
|
|||
throw new Exception('No name and photo for URL '.$gcontact['url']);
|
||||
}
|
||||
|
||||
if (!in_array($gcontact['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA])) {
|
||||
if (!in_array($gcontact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
|
||||
throw new Exception('No federated network ('.$gcontact['network'].') detected for URL '.$gcontact['url']);
|
||||
}
|
||||
|
||||
|
@ -460,14 +461,14 @@ class GContact
|
|||
// return $list;
|
||||
//}
|
||||
|
||||
$network = [NETWORK_DFRN];
|
||||
$network = [Protocol::DFRN];
|
||||
|
||||
if (Config::get('system', 'diaspora_enabled')) {
|
||||
$network[] = NETWORK_DIASPORA;
|
||||
$network[] = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
if (!Config::get('system', 'ostatus_disabled')) {
|
||||
$network[] = NETWORK_OSTATUS;
|
||||
$network[] = Protocol::OSTATUS;
|
||||
}
|
||||
|
||||
$sql_network = implode("', '", $network);
|
||||
|
@ -580,8 +581,8 @@ class GContact
|
|||
// Query your contacts from Friendica and Redmatrix/Hubzilla for their contacts
|
||||
$r = q(
|
||||
"SELECT DISTINCT(`poco`) AS `poco` FROM `contact` WHERE `network` IN ('%s', '%s')",
|
||||
DBA::escape(NETWORK_DFRN),
|
||||
DBA::escape(NETWORK_DIASPORA)
|
||||
DBA::escape(Protocol::DFRN),
|
||||
DBA::escape(Protocol::DIASPORA)
|
||||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
|
@ -634,9 +635,9 @@ class GContact
|
|||
*/
|
||||
public static function fixAlternateContactAddress(&$contact)
|
||||
{
|
||||
if (($contact["network"] == NETWORK_OSTATUS) && PortableContact::alternateOStatusUrl($contact["url"])) {
|
||||
if (($contact["network"] == Protocol::OSTATUS) && PortableContact::alternateOStatusUrl($contact["url"])) {
|
||||
$data = Probe::uri($contact["url"]);
|
||||
if ($contact["network"] == NETWORK_OSTATUS) {
|
||||
if ($contact["network"] == Protocol::OSTATUS) {
|
||||
logger("Fix primary url from ".$contact["url"]." to ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
|
||||
$contact["url"] = $data["url"];
|
||||
$contact["addr"] = $data["addr"];
|
||||
|
@ -665,13 +666,13 @@ class GContact
|
|||
return false;
|
||||
}
|
||||
|
||||
if (in_array($contact["network"], [NETWORK_PHANTOM])) {
|
||||
if (in_array($contact["network"], [Protocol::PHANTOM])) {
|
||||
logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($contact["network"] == NETWORK_STATUSNET) {
|
||||
$contact["network"] = NETWORK_OSTATUS;
|
||||
if ($contact["network"] == Protocol::STATUSNET) {
|
||||
$contact["network"] = Protocol::OSTATUS;
|
||||
}
|
||||
|
||||
// All new contacts are hidden by default
|
||||
|
@ -683,7 +684,7 @@ class GContact
|
|||
self::fixAlternateContactAddress($contact);
|
||||
|
||||
// Remove unwanted parts from the contact url (e.g. "?zrl=...")
|
||||
if (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) {
|
||||
if (in_array($contact["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
|
||||
$contact["url"] = self::cleanContactUrl($contact["url"]);
|
||||
}
|
||||
|
||||
|
@ -697,7 +698,7 @@ class GContact
|
|||
$gcontact_id = $r[0]["id"];
|
||||
|
||||
// Update every 90 days
|
||||
if (in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
|
||||
if (in_array($r[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
|
||||
$last_failure_str = $r[0]["last_failure"];
|
||||
$last_failure = strtotime($r[0]["last_failure"]);
|
||||
$last_contact_str = $r[0]["last_contact"];
|
||||
|
@ -735,7 +736,7 @@ class GContact
|
|||
if (DBA::isResult($r)) {
|
||||
$gcontact_id = $r[0]["id"];
|
||||
|
||||
$doprobing = in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""]);
|
||||
$doprobing = in_array($r[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""]);
|
||||
}
|
||||
}
|
||||
DBA::unlock();
|
||||
|
@ -810,8 +811,8 @@ class GContact
|
|||
|
||||
$fields["hide"] = $public_contact[0]["hide"];
|
||||
|
||||
if ($contact["network"] == NETWORK_STATUSNET) {
|
||||
$contact["network"] = NETWORK_OSTATUS;
|
||||
if ($contact["network"] == Protocol::STATUSNET) {
|
||||
$contact["network"] = Protocol::OSTATUS;
|
||||
}
|
||||
|
||||
// Replace alternate OStatus user format with the primary one
|
||||
|
@ -821,13 +822,13 @@ class GContact
|
|||
$contact["updated"] = DateTimeFormat::utcNow();
|
||||
}
|
||||
|
||||
if ($contact["network"] == NETWORK_TWITTER) {
|
||||
if ($contact["network"] == Protocol::TWITTER) {
|
||||
$contact["server_url"] = 'http://twitter.com';
|
||||
}
|
||||
|
||||
if ($contact["server_url"] == "") {
|
||||
$data = Probe::uri($contact["url"]);
|
||||
if ($data["network"] != NETWORK_PHANTOM) {
|
||||
if ($data["network"] != Protocol::PHANTOM) {
|
||||
$contact["server_url"] = $data['baseurl'];
|
||||
}
|
||||
} else {
|
||||
|
@ -923,7 +924,7 @@ class GContact
|
|||
{
|
||||
$data = Probe::uri($url);
|
||||
|
||||
if (in_array($data["network"], [NETWORK_PHANTOM])) {
|
||||
if (in_array($data["network"], [Protocol::PHANTOM])) {
|
||||
logger("Invalid network for contact url ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
@ -972,7 +973,7 @@ class GContact
|
|||
"hide" => ($r[0]["hidewall"] || !$r[0]["net-publish"]),
|
||||
"nick" => $r[0]["nickname"], "addr" => $addr,
|
||||
"connect" => $addr, "server_url" => System::baseUrl(),
|
||||
"generation" => 1, "network" => NETWORK_DFRN];
|
||||
"generation" => 1, "network" => Protocol::DFRN];
|
||||
|
||||
self::update($gcontact);
|
||||
}
|
||||
|
@ -1028,7 +1029,7 @@ class GContact
|
|||
"name" => $user->fullname,
|
||||
"addr" => $user->nickname."@".$hostname,
|
||||
"nick" => $user->nickname,
|
||||
"network" => NETWORK_OSTATUS,
|
||||
"network" => Protocol::OSTATUS,
|
||||
"photo" => System::baseUrl()."/images/person-175.jpg"];
|
||||
|
||||
if (isset($user->bio)) {
|
||||
|
@ -1052,7 +1053,7 @@ class GContact
|
|||
|
||||
$r = q(
|
||||
"SELECT `nurl`, `url` FROM `gserver` WHERE `last_contact` >= `last_failure` AND `network` = '%s' AND `last_poco_query` < '%s' ORDER BY RAND() LIMIT 5",
|
||||
DBA::escape(NETWORK_OSTATUS),
|
||||
DBA::escape(Protocol::OSTATUS),
|
||||
DBA::escape($last_update)
|
||||
);
|
||||
|
||||
|
@ -1076,7 +1077,7 @@ class GContact
|
|||
AND `last_contact` >= `last_failure`
|
||||
AND `updated` > UTC_TIMESTAMP - INTERVAL 1 MONTH
|
||||
ORDER BY rand() LIMIT 1",
|
||||
DBA::escape(NETWORK_DFRN)
|
||||
DBA::escape(Protocol::DFRN)
|
||||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
|
|
|
@ -12,6 +12,7 @@ use Friendica\Core\Addon;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Lock;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -175,7 +176,7 @@ class Item extends BaseObject
|
|||
|
||||
// We can always comment on posts from these networks
|
||||
if (array_key_exists('writable', $row) &&
|
||||
in_array($row['internal-network'], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) {
|
||||
in_array($row['internal-network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
|
||||
$row['writable'] = true;
|
||||
}
|
||||
|
||||
|
@ -1254,7 +1255,7 @@ class Item extends BaseObject
|
|||
if ($notify) {
|
||||
$item['wall'] = 1;
|
||||
$item['origin'] = 1;
|
||||
$item['network'] = NETWORK_DFRN;
|
||||
$item['network'] = Protocol::DFRN;
|
||||
$item['protocol'] = Conversation::PARCEL_DFRN;
|
||||
|
||||
if (is_int($notify)) {
|
||||
|
@ -1263,7 +1264,7 @@ class Item extends BaseObject
|
|||
$priority = PRIORITY_HIGH;
|
||||
}
|
||||
} else {
|
||||
$item['network'] = trim(defaults($item, 'network', NETWORK_PHANTOM));
|
||||
$item['network'] = trim(defaults($item, 'network', Protocol::PHANTOM));
|
||||
}
|
||||
|
||||
$item['guid'] = self::guid($item, $notify);
|
||||
|
@ -1296,7 +1297,7 @@ class Item extends BaseObject
|
|||
|
||||
// Converting the plink
|
||||
/// @TODO Check if this is really still needed
|
||||
if ($item['network'] == NETWORK_OSTATUS) {
|
||||
if ($item['network'] == Protocol::OSTATUS) {
|
||||
if (isset($item['plink'])) {
|
||||
$item['plink'] = OStatus::convertHref($item['plink']);
|
||||
} elseif (isset($item['uri'])) {
|
||||
|
@ -1343,10 +1344,10 @@ class Item extends BaseObject
|
|||
* We have to check several networks since Friendica posts could be repeated
|
||||
* via OStatus (maybe Diasporsa as well)
|
||||
*/
|
||||
if (in_array($item['network'], [NETWORK_DIASPORA, NETWORK_DFRN, NETWORK_OSTATUS, ""])) {
|
||||
if (in_array($item['network'], [Protocol::DIASPORA, Protocol::DFRN, Protocol::OSTATUS, ""])) {
|
||||
$condition = ["`uri` = ? AND `uid` = ? AND `network` IN (?, ?, ?)",
|
||||
trim($item['uri']), $item['uid'],
|
||||
NETWORK_DIASPORA, NETWORK_DFRN, NETWORK_OSTATUS];
|
||||
Protocol::DIASPORA, Protocol::DFRN, Protocol::OSTATUS];
|
||||
$existing = self::selectFirst(['id', 'network'], $condition);
|
||||
if (DBA::isResult($existing)) {
|
||||
// We only log the entries with a different user id than 0. Otherwise we would have too many false positives
|
||||
|
@ -1462,10 +1463,10 @@ class Item extends BaseObject
|
|||
unset($item['owner-name']);
|
||||
unset($item['owner-avatar']);
|
||||
|
||||
if ($item['network'] == NETWORK_PHANTOM) {
|
||||
if ($item['network'] == Protocol::PHANTOM) {
|
||||
logger('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG);
|
||||
|
||||
$item['network'] = NETWORK_DFRN;
|
||||
$item['network'] = Protocol::DFRN;
|
||||
logger("Set network to " . $item["network"] . " for " . $item["uri"], LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
|
@ -1588,14 +1589,14 @@ class Item extends BaseObject
|
|||
$item['thr-parent-id'] = ItemURI::getIdByURI($item['thr-parent']);
|
||||
|
||||
$condition = ["`uri` = ? AND `network` IN (?, ?) AND `uid` = ?",
|
||||
$item['uri'], $item['network'], NETWORK_DFRN, $item['uid']];
|
||||
$item['uri'], $item['network'], Protocol::DFRN, $item['uid']];
|
||||
if (self::exists($condition)) {
|
||||
logger('duplicated item with the same uri found. '.print_r($item,true));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// On Friendica and Diaspora the GUID is unique
|
||||
if (in_array($item['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
|
||||
if (in_array($item['network'], [Protocol::DFRN, Protocol::DIASPORA])) {
|
||||
$condition = ['guid' => $item['guid'], 'uid' => $item['uid']];
|
||||
if (self::exists($condition)) {
|
||||
logger('duplicated item with the same guid found. '.print_r($item,true));
|
||||
|
@ -2044,7 +2045,7 @@ class Item extends BaseObject
|
|||
|
||||
// Only distribute public items from native networks
|
||||
$condition = ['id' => $itemid, 'uid' => 0,
|
||||
'network' => [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""],
|
||||
'network' => [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""],
|
||||
'visible' => true, 'deleted' => false, 'moderated' => false, 'private' => false];
|
||||
$item = self::selectFirst(self::ITEM_FIELDLIST, ['id' => $itemid]);
|
||||
if (!DBA::isResult($item)) {
|
||||
|
@ -2166,7 +2167,7 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// is it an entry from a connector? Only add an entry for natively connected networks
|
||||
if (!in_array($item["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
|
||||
if (!in_array($item["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2256,7 +2257,7 @@ class Item extends BaseObject
|
|||
|
||||
// If this was a comment to a Diaspora post we don't get our comment back.
|
||||
// This means that we have to distribute the comment by ourselves.
|
||||
if ($origin && self::exists(['id' => $parent, 'network' => NETWORK_DIASPORA])) {
|
||||
if ($origin && self::exists(['id' => $parent, 'network' => Protocol::DIASPORA])) {
|
||||
self::distribute($public_shadow);
|
||||
}
|
||||
}
|
||||
|
@ -2355,7 +2356,7 @@ class Item extends BaseObject
|
|||
$update = (!$arr['private'] && ((defaults($arr, 'author-link', '') === defaults($arr, 'owner-link', '')) || ($arr["parent-uri"] === $arr["uri"])));
|
||||
|
||||
// Is it a forum? Then we don't care about the rules from above
|
||||
if (!$update && ($arr["network"] == NETWORK_DFRN) && ($arr["parent-uri"] === $arr["uri"])) {
|
||||
if (!$update && ($arr["network"] == Protocol::DFRN) && ($arr["parent-uri"] === $arr["uri"])) {
|
||||
if (DBA::exists('contact', ['id' => $arr['contact-id'], 'forum' => true])) {
|
||||
$update = true;
|
||||
}
|
||||
|
@ -2594,7 +2595,7 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// Prevent the forwarding of posts that are forwarded
|
||||
if (!empty($datarray["extid"]) && ($datarray["extid"] == NETWORK_DFRN)) {
|
||||
if (!empty($datarray["extid"]) && ($datarray["extid"] == Protocol::DFRN)) {
|
||||
logger('Already forwarded', LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
@ -2611,7 +2612,7 @@ class Item extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
if (($contact['network'] != NETWORK_FEED) && $datarray['private']) {
|
||||
if (($contact['network'] != Protocol::FEED) && $datarray['private']) {
|
||||
logger('Not public', LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
@ -2640,13 +2641,13 @@ class Item extends BaseObject
|
|||
unset($datarray['author-id']);
|
||||
}
|
||||
|
||||
if ($contact['network'] != NETWORK_FEED) {
|
||||
if ($contact['network'] != Protocol::FEED) {
|
||||
$datarray["guid"] = System::createGUID(32);
|
||||
unset($datarray["plink"]);
|
||||
$datarray["uri"] = self::newURI($contact['uid'], $datarray["guid"]);
|
||||
$datarray["parent-uri"] = $datarray["uri"];
|
||||
$datarray["thr-parent"] = $datarray["uri"];
|
||||
$datarray["extid"] = NETWORK_DFRN;
|
||||
$datarray["extid"] = Protocol::DFRN;
|
||||
$urlpart = parse_url($datarray2['author-link']);
|
||||
$datarray["app"] = $urlpart["host"];
|
||||
} else {
|
||||
|
@ -2654,7 +2655,7 @@ class Item extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
if ($contact['network'] != NETWORK_FEED) {
|
||||
if ($contact['network'] != Protocol::FEED) {
|
||||
// Store the original post
|
||||
$result = self::insert($datarray2, false, false);
|
||||
logger('remote-self post original item - Contact '.$contact['url'].' return '.$result.' Item '.print_r($datarray2, true), LOGGER_DEBUG);
|
||||
|
@ -3076,7 +3077,7 @@ class Item extends BaseObject
|
|||
'contact-id' => $item_contact_id,
|
||||
'wall' => $item['wall'],
|
||||
'origin' => 1,
|
||||
'network' => NETWORK_DFRN,
|
||||
'network' => Protocol::DFRN,
|
||||
'gravity' => GRAVITY_ACTIVITY,
|
||||
'parent' => $item['id'],
|
||||
'parent-uri' => $item['uri'],
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace Friendica\Model;
|
|||
use Friendica\BaseObject;
|
||||
use Friendica\Content\Text;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Protocol;
|
||||
|
||||
require_once 'boot.php';
|
||||
require_once 'include/items.php';
|
||||
|
@ -68,11 +69,13 @@ class ItemContent extends BaseObject
|
|||
} else {// Try to guess the correct target network
|
||||
switch ($htmlmode) {
|
||||
case 8:
|
||||
$abstract = Text\BBCode::getAbstract($item['body'], NETWORK_TWITTER);
|
||||
$abstract = Text\BBCode::getAbstract($item['body'], Protocol::TWITTER);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
$abstract = Text\BBCode::getAbstract($item['body'], NETWORK_STATUSNET);
|
||||
$abstract = Text\BBCode::getAbstract($item['body'], Protocol::STATUSNET);
|
||||
break;
|
||||
|
||||
default: // We don't know the exact target.
|
||||
// We fetch an abstract since there is a posting limit.
|
||||
if ($limit > 0) {
|
||||
|
|
|
@ -13,6 +13,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;
|
||||
|
@ -136,7 +137,7 @@ class Profile
|
|||
$a->profile_uid = $pdata['profile_uid'];
|
||||
|
||||
$a->profile['mobile-theme'] = PConfig::get($a->profile['profile_uid'], 'system', 'mobile_theme');
|
||||
$a->profile['network'] = NETWORK_DFRN;
|
||||
$a->profile['network'] = Protocol::DFRN;
|
||||
|
||||
$a->page['title'] = $a->profile['name'] . ' @ ' . Config::get('config', 'sitename');
|
||||
|
||||
|
@ -280,7 +281,7 @@ class Profile
|
|||
|
||||
$profile['picdate'] = urlencode(defaults($profile, 'picdate', ''));
|
||||
|
||||
if (($profile['network'] != '') && ($profile['network'] != NETWORK_DFRN)) {
|
||||
if (($profile['network'] != '') && ($profile['network'] != Protocol::DFRN)) {
|
||||
$profile['network_name'] = format_network_name($profile['network'], $profile['url']);
|
||||
} else {
|
||||
$profile['network_name'] = '';
|
||||
|
@ -321,7 +322,7 @@ class Profile
|
|||
}
|
||||
}
|
||||
|
||||
if ($connect && ($profile['network'] != NETWORK_DFRN) && !isset($profile['remoteconnect'])) {
|
||||
if ($connect && ($profile['network'] != Protocol::DFRN) && !isset($profile['remoteconnect'])) {
|
||||
$connect = false;
|
||||
}
|
||||
|
||||
|
@ -330,7 +331,7 @@ class Profile
|
|||
$remoteconnect = $profile['remoteconnect'];
|
||||
}
|
||||
|
||||
if ($connect && ($profile['network'] == NETWORK_DFRN) && !isset($remoteconnect)) {
|
||||
if ($connect && ($profile['network'] == Protocol::DFRN) && !isset($remoteconnect)) {
|
||||
$subscribe_feed = L10n::t('Atom feed');
|
||||
} else {
|
||||
$subscribe_feed = false;
|
||||
|
@ -471,9 +472,9 @@ class Profile
|
|||
AND NOT `hidden` AND NOT `archive`
|
||||
AND `network` IN ('%s', '%s', '%s', '')",
|
||||
intval($profile['uid']),
|
||||
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)) {
|
||||
$contacts = intval($r[0]['total']);
|
||||
|
@ -1016,7 +1017,7 @@ class Profile
|
|||
$urlparts = parse_url($my_url);
|
||||
|
||||
$result = Cache::get('gprobe:' . $urlparts['host']);
|
||||
if ((!is_null($result)) && (in_array($result['network'], [NETWORK_FEED, NETWORK_PHANTOM]))) {
|
||||
if ((!is_null($result)) && (in_array($result['network'], [Protocol::FEED, Protocol::PHANTOM]))) {
|
||||
logger('DDoS attempt detected for ' . $urlparts['host'] . ' by ' . $_SERVER['REMOTE_ADDR'] . '. server data: ' . print_r($_SERVER, true), LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ use Friendica\Core\Addon;
|
|||
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;
|
||||
|
@ -88,7 +89,7 @@ class User
|
|||
{
|
||||
$default_group = 0;
|
||||
|
||||
if ($network == NETWORK_OSTATUS) {
|
||||
if ($network == Protocol::OSTATUS) {
|
||||
$default_group = PConfig::get($uid, "ostatus", "default_group");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue