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:
committed by
Hypolite Petovan
parent
c623465df2
commit
e06fc2aa69
@@ -6,6 +6,7 @@ namespace Friendica\Content;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
/**
|
||||
@@ -74,21 +75,21 @@ class ContactSelector
|
||||
public static function networkToName($s, $profile = "")
|
||||
{
|
||||
$nets = [
|
||||
NETWORK_DFRN => L10n::t('Friendica'),
|
||||
NETWORK_OSTATUS => L10n::t('OStatus'),
|
||||
NETWORK_FEED => L10n::t('RSS/Atom'),
|
||||
NETWORK_MAIL => L10n::t('Email'),
|
||||
NETWORK_DIASPORA => L10n::t('Diaspora'),
|
||||
NETWORK_ZOT => L10n::t('Zot!'),
|
||||
NETWORK_LINKEDIN => L10n::t('LinkedIn'),
|
||||
NETWORK_XMPP => L10n::t('XMPP/IM'),
|
||||
NETWORK_MYSPACE => L10n::t('MySpace'),
|
||||
NETWORK_GPLUS => L10n::t('Google+'),
|
||||
NETWORK_PUMPIO => L10n::t('pump.io'),
|
||||
NETWORK_TWITTER => L10n::t('Twitter'),
|
||||
NETWORK_DIASPORA2 => L10n::t('Diaspora Connector'),
|
||||
NETWORK_STATUSNET => L10n::t('GNU Social Connector'),
|
||||
NETWORK_PNUT => L10n::t('pnut')
|
||||
Protocol::DFRN => L10n::t('Friendica'),
|
||||
Protocol::OSTATUS => L10n::t('OStatus'),
|
||||
Protocol::FEED => L10n::t('RSS/Atom'),
|
||||
Protocol::MAIL => L10n::t('Email'),
|
||||
Protocol::DIASPORA => L10n::t('Diaspora'),
|
||||
Protocol::ZOT => L10n::t('Zot!'),
|
||||
Protocol::LINKEDIN => L10n::t('LinkedIn'),
|
||||
Protocol::XMPP => L10n::t('XMPP/IM'),
|
||||
Protocol::MYSPACE => L10n::t('MySpace'),
|
||||
Protocol::GPLUS => L10n::t('Google+'),
|
||||
Protocol::PUMPIO => L10n::t('pump.io'),
|
||||
Protocol::TWITTER => L10n::t('Twitter'),
|
||||
Protocol::DIASPORA2 => L10n::t('Diaspora Connector'),
|
||||
Protocol::STATUSNET => L10n::t('GNU Social Connector'),
|
||||
Protocol::PNUT => L10n::t('pnut'),
|
||||
];
|
||||
|
||||
Addon::callHooks('network_to_name', $nets);
|
||||
@@ -98,7 +99,7 @@ class ContactSelector
|
||||
|
||||
$networkname = str_replace($search, $replace, $s);
|
||||
|
||||
if ((in_array($s, [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) && ($profile != "")) {
|
||||
if ((in_array($s, [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) && ($profile != "")) {
|
||||
$r = DBA::fetchFirst("SELECT `gserver`.`platform` FROM `gcontact`
|
||||
INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
|
||||
WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
|
||||
|
||||
@@ -10,6 +10,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\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
@@ -83,27 +84,27 @@ class Widget
|
||||
$networks = ['face', 'apdn'];
|
||||
|
||||
if (!Addon::isEnabled("statusnet")) {
|
||||
$networks[] = NETWORK_STATUSNET;
|
||||
$networks[] = Protocol::STATUSNET;
|
||||
}
|
||||
|
||||
if (!Addon::isEnabled("pumpio")) {
|
||||
$networks[] = NETWORK_PUMPIO;
|
||||
$networks[] = Protocol::PUMPIO;
|
||||
}
|
||||
|
||||
if (!Addon::isEnabled("twitter")) {
|
||||
$networks[] = NETWORK_TWITTER;
|
||||
$networks[] = Protocol::TWITTER;
|
||||
}
|
||||
|
||||
if (Config::get("system", "ostatus_disabled")) {
|
||||
$networks[] = NETWORK_OSTATUS;
|
||||
$networks[] = Protocol::OSTATUS;
|
||||
}
|
||||
|
||||
if (!Config::get("system", "diaspora_enabled")) {
|
||||
$networks[] = NETWORK_DIASPORA;
|
||||
$networks[] = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
if (!Addon::isEnabled("pnut")) {
|
||||
$networks[] = NETWORK_PNUT;
|
||||
$networks[] = Protocol::PNUT;
|
||||
}
|
||||
|
||||
if (!sizeof($networks)) {
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Friendica\Core;
|
||||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GContact;
|
||||
@@ -46,18 +47,21 @@ class ACL extends BaseObject
|
||||
|
||||
switch (defaults($options, 'networks', Protocol::PHANTOM)) {
|
||||
case 'DFRN_ONLY':
|
||||
$networks = [NETWORK_DFRN];
|
||||
$networks = [Protocol::DFRN];
|
||||
break;
|
||||
|
||||
case 'PRIVATE':
|
||||
$networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
|
||||
$networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA];
|
||||
break;
|
||||
|
||||
case 'TWO_WAY':
|
||||
if (!empty($a->user['prvnets'])) {
|
||||
$networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
|
||||
$networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA];
|
||||
} else {
|
||||
$networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS];
|
||||
$networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA, Protocol::OSTATUS];
|
||||
}
|
||||
break;
|
||||
|
||||
default: /// @TODO Maybe log this call?
|
||||
break;
|
||||
}
|
||||
@@ -148,7 +152,7 @@ class ACL extends BaseObject
|
||||
// When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector
|
||||
// to one recipient. By default our selector allows multiple selects amongst all contacts.
|
||||
$sql_extra = sprintf(" AND `rel` = %d ", intval(Contact::FRIEND));
|
||||
$sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ", NETWORK_DFRN, NETWORK_DIASPORA);
|
||||
$sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ", Protocol::DFRN, Protocol::DIASPORA);
|
||||
|
||||
$tabindex_attr = !empty($tabindex) ? ' tabindex="' . intval($tabindex) . '"' : '';
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Friendica\Core;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
@@ -235,7 +236,7 @@ class NotificationsManager extends BaseObject
|
||||
}
|
||||
|
||||
// For feed items we use the user's contact, since the avatar is mostly self choosen.
|
||||
if (!empty($it['network']) && $it['network'] == NETWORK_FEED) {
|
||||
if (!empty($it['network']) && $it['network'] == Protocol::FEED) {
|
||||
$it['author-avatar'] = $it['contact-avatar'];
|
||||
}
|
||||
|
||||
@@ -639,14 +640,14 @@ class NotificationsManager extends BaseObject
|
||||
$it = $this->getMissingIntroData($it);
|
||||
|
||||
// Don't show these data until you are connected. Diaspora is doing the same.
|
||||
if ($it['gnetwork'] === NETWORK_DIASPORA) {
|
||||
if ($it['gnetwork'] === Protocol::DIASPORA) {
|
||||
$it['glocation'] = "";
|
||||
$it['gabout'] = "";
|
||||
$it['ggender'] = "";
|
||||
}
|
||||
$intro = [
|
||||
'label' => (($it['network'] !== NETWORK_OSTATUS) ? 'friend_request' : 'follower'),
|
||||
'notify_type' => (($it['network'] !== NETWORK_OSTATUS) ? L10n::t('Friend/Connect Request') : L10n::t('New Follower')),
|
||||
'label' => (($it['network'] !== Protocol::OSTATUS) ? 'friend_request' : 'follower'),
|
||||
'notify_type' => (($it['network'] !== Protocol::OSTATUS) ? L10n::t('Friend/Connect Request') : L10n::t('New Follower')),
|
||||
'dfrn_id' => $it['issued-id'],
|
||||
'uid' => $_SESSION['uid'],
|
||||
'intro_id' => $it['intro_id'],
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
namespace Friendica\Core;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Object\Image;
|
||||
@@ -182,12 +183,12 @@ class UserImport
|
||||
$contact["avatar-date"] = NULL_DATE;
|
||||
|
||||
switch ($contact['network']) {
|
||||
case NETWORK_DFRN:
|
||||
case NETWORK_DIASPORA:
|
||||
case Protocol::DFRN:
|
||||
case Protocol::DIASPORA:
|
||||
// send relocate message (below)
|
||||
break;
|
||||
case NETWORK_FEED:
|
||||
case NETWORK_MAIL:
|
||||
case Protocol::FEED:
|
||||
case Protocol::MAIL:
|
||||
// Nothing to do
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
namespace Friendica\Database;
|
||||
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\ItemURI;
|
||||
@@ -81,7 +82,7 @@ class PostUpdate
|
||||
|
||||
$r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1",
|
||||
intval($start_id), intval($end_id),
|
||||
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 (!$r) {
|
||||
Config::set("system", "post_update_version", 1194);
|
||||
logger("Update is done", LOGGER_DEBUG);
|
||||
@@ -95,7 +96,7 @@ class PostUpdate
|
||||
|
||||
$r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1000,1",
|
||||
intval($start_id), intval($end_id),
|
||||
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 ($r) {
|
||||
$pos_id = $r[0]["id"];
|
||||
} else {
|
||||
@@ -105,7 +106,7 @@ class PostUpdate
|
||||
|
||||
q("UPDATE `item` ".$query2." SET `item`.`global` = 1 ".$query3,
|
||||
intval($start_id), intval($pos_id),
|
||||
DBA::escape(NETWORK_DFRN), DBA::escape(NETWORK_DIASPORA), DBA::escape(NETWORK_OSTATUS));
|
||||
DBA::escape(Protocol::DFRN), DBA::escape(Protocol::DIASPORA), DBA::escape(Protocol::OSTATUS));
|
||||
|
||||
logger("Done", LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Friendica\Network;
|
||||
use DOMDocument;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
@@ -362,20 +363,20 @@ class Probe
|
||||
}
|
||||
|
||||
if (empty($data["network"])) {
|
||||
$data["network"] = NETWORK_PHANTOM;
|
||||
$data["network"] = Protocol::PHANTOM;
|
||||
}
|
||||
|
||||
$data = self::rearrangeData($data);
|
||||
|
||||
// Only store into the cache if the value seems to be valid
|
||||
if (!in_array($data['network'], [NETWORK_PHANTOM, NETWORK_MAIL])) {
|
||||
if (!in_array($data['network'], [Protocol::PHANTOM, Protocol::MAIL])) {
|
||||
Cache::set("Probe::uri:".$network.":".$uri, $data, CACHE_DAY);
|
||||
|
||||
/// @todo temporary fix - we need a real contact update function that updates only changing fields
|
||||
/// The biggest problem is the avatar picture that could have a reduced image size.
|
||||
/// It should only be updated if the existing picture isn't existing anymore.
|
||||
/// We only update the contact when it is no probing for a specific network.
|
||||
if (($data['network'] != NETWORK_FEED)
|
||||
if (($data['network'] != Protocol::FEED)
|
||||
&& ($network == "")
|
||||
&& $data["name"]
|
||||
&& $data["nick"]
|
||||
@@ -568,7 +569,7 @@ class Probe
|
||||
}
|
||||
|
||||
if ($host == 'twitter.com') {
|
||||
return ["network" => NETWORK_TWITTER];
|
||||
return ["network" => Protocol::TWITTER];
|
||||
}
|
||||
$lrdd = self::hostMeta($host);
|
||||
|
||||
@@ -599,7 +600,7 @@ class Probe
|
||||
return self::mail($uri, $uid);
|
||||
}
|
||||
|
||||
if ($network == NETWORK_MAIL) {
|
||||
if ($network == Protocol::MAIL) {
|
||||
return self::mail($uri, $uid);
|
||||
}
|
||||
// Remove "acct:" from the URI
|
||||
@@ -609,7 +610,7 @@ class Probe
|
||||
$nick = substr($uri, 0, strpos($uri, '@'));
|
||||
|
||||
if (strpos($uri, '@twitter.com')) {
|
||||
return ["network" => NETWORK_TWITTER];
|
||||
return ["network" => Protocol::TWITTER];
|
||||
}
|
||||
$lrdd = self::hostMeta($host);
|
||||
|
||||
@@ -670,19 +671,19 @@ class Probe
|
||||
|
||||
logger("Probing ".$uri, LOGGER_DEBUG);
|
||||
|
||||
if (in_array($network, ["", NETWORK_DFRN])) {
|
||||
if (in_array($network, ["", Protocol::DFRN])) {
|
||||
$result = self::dfrn($webfinger);
|
||||
}
|
||||
if ((!$result && ($network == "")) || ($network == NETWORK_DIASPORA)) {
|
||||
if ((!$result && ($network == "")) || ($network == Protocol::DIASPORA)) {
|
||||
$result = self::diaspora($webfinger);
|
||||
}
|
||||
if ((!$result && ($network == "")) || ($network == NETWORK_OSTATUS)) {
|
||||
if ((!$result && ($network == "")) || ($network == Protocol::OSTATUS)) {
|
||||
$result = self::ostatus($webfinger);
|
||||
}
|
||||
if ((!$result && ($network == "")) || ($network == NETWORK_PUMPIO)) {
|
||||
if ((!$result && ($network == "")) || ($network == Protocol::PUMPIO)) {
|
||||
$result = self::pumpio($webfinger, $addr);
|
||||
}
|
||||
if ((!$result && ($network == "")) || ($network == NETWORK_FEED)) {
|
||||
if ((!$result && ($network == "")) || ($network == Protocol::FEED)) {
|
||||
$result = self::feed($uri);
|
||||
} else {
|
||||
// We overwrite the detected nick with our try if the previois routines hadn't detected it.
|
||||
@@ -697,7 +698,7 @@ class Probe
|
||||
}
|
||||
|
||||
if (empty($result["network"])) {
|
||||
$result["network"] = NETWORK_PHANTOM;
|
||||
$result["network"] = Protocol::PHANTOM;
|
||||
}
|
||||
|
||||
if (empty($result["url"])) {
|
||||
@@ -960,7 +961,7 @@ class Probe
|
||||
$data = [];
|
||||
foreach ($webfinger["links"] as $link) {
|
||||
if (($link["rel"] == NAMESPACE_DFRN) && ($link["href"] != "")) {
|
||||
$data["network"] = NETWORK_DFRN;
|
||||
$data["network"] = Protocol::DFRN;
|
||||
} elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) {
|
||||
$data["poll"] = $link["href"];
|
||||
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && ($link["type"] == "text/html") && ($link["href"] != "")) {
|
||||
@@ -1215,7 +1216,7 @@ class Probe
|
||||
&& isset($data["pubkey"])
|
||||
&& ($hcard_url != "")
|
||||
) {
|
||||
$data["network"] = NETWORK_DIASPORA;
|
||||
$data["network"] = Protocol::DIASPORA;
|
||||
|
||||
// The Diaspora handle must always be lowercase
|
||||
if (!empty($data["addr"])) {
|
||||
@@ -1302,7 +1303,7 @@ class Probe
|
||||
&& isset($data["poll"])
|
||||
&& isset($data["url"])
|
||||
) {
|
||||
$data["network"] = NETWORK_OSTATUS;
|
||||
$data["network"] = Protocol::OSTATUS;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -1446,7 +1447,7 @@ class Probe
|
||||
// So we unset all data that isn't used at the moment
|
||||
unset($data["dialback"]);
|
||||
|
||||
$data["network"] = NETWORK_PUMPIO;
|
||||
$data["network"] = Protocol::PUMPIO;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -1569,7 +1570,7 @@ class Probe
|
||||
$data["baseurl"] = $data["url"];
|
||||
}
|
||||
|
||||
$data["network"] = NETWORK_FEED;
|
||||
$data["network"] = Protocol::FEED;
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -1619,7 +1620,7 @@ class Probe
|
||||
|
||||
$data = [];
|
||||
$data["addr"] = $uri;
|
||||
$data["network"] = NETWORK_MAIL;
|
||||
$data["network"] = Protocol::MAIL;
|
||||
$data["name"] = substr($uri, 0, strpos($uri, '@'));
|
||||
$data["nick"] = $data["name"];
|
||||
$data["photo"] = Network::lookupAvatarByEmail($uri);
|
||||
|
||||
@@ -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\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
@@ -84,14 +85,14 @@ class Post extends BaseObject
|
||||
if (!empty($data['children'])) {
|
||||
foreach ($data['children'] as $item) {
|
||||
// Only add will be displayed
|
||||
if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
|
||||
if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
|
||||
continue;
|
||||
} elseif (!visible_activity($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// You can always comment on Diaspora and OStatus items
|
||||
if (in_array($item['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA]) && (local_user() == $item['uid'])) {
|
||||
if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (local_user() == $item['uid'])) {
|
||||
$item['writable'] = true;
|
||||
}
|
||||
|
||||
@@ -323,17 +324,17 @@ class Post extends BaseObject
|
||||
$owner_name_e = $this->getOwnerName();
|
||||
|
||||
// Disable features that aren't available in several networks
|
||||
if (!in_array($item["network"], [NETWORK_DFRN, NETWORK_DIASPORA]) && isset($buttons["dislike"])) {
|
||||
if (!in_array($item["network"], [Protocol::DFRN, Protocol::DIASPORA]) && isset($buttons["dislike"])) {
|
||||
unset($buttons["dislike"]);
|
||||
$isevent = false;
|
||||
$tagger = '';
|
||||
}
|
||||
|
||||
if (($item["network"] == NETWORK_FEED) && isset($buttons["like"])) {
|
||||
if (($item["network"] == Protocol::FEED) && isset($buttons["like"])) {
|
||||
unset($buttons["like"]);
|
||||
}
|
||||
|
||||
if (($item["network"] == NETWORK_MAIL) && isset($buttons["like"])) {
|
||||
if (($item["network"] == Protocol::MAIL) && isset($buttons["like"])) {
|
||||
unset($buttons["like"]);
|
||||
}
|
||||
|
||||
@@ -489,7 +490,7 @@ class Post extends BaseObject
|
||||
/*
|
||||
* Only add what will be displayed
|
||||
*/
|
||||
if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
|
||||
if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
|
||||
return false;
|
||||
} elseif (activity_match($item->getDataValue('verb'), ACTIVITY_LIKE) || activity_match($item->getDataValue('verb'), ACTIVITY_DISLIKE)) {
|
||||
return false;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
namespace Friendica\Object;
|
||||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Object\Post;
|
||||
|
||||
require_once 'boot.php';
|
||||
@@ -143,7 +144,7 @@ class Thread extends BaseObject
|
||||
/*
|
||||
* Only add will be displayed
|
||||
*/
|
||||
if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
|
||||
if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
|
||||
logger('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').', LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
@@ -176,7 +177,7 @@ class Thread extends BaseObject
|
||||
$i = 0;
|
||||
|
||||
foreach ($this->parents as $item) {
|
||||
if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
|
||||
if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Friendica\Worker;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
@@ -188,11 +189,11 @@ class Cron
|
||||
AND `contact`.`network` IN ('%s', '%s', '%s', '%s', '%s') $sql_extra
|
||||
AND NOT `contact`.`self` AND NOT `contact`.`blocked`
|
||||
WHERE NOT `user`.`account_expired` AND NOT `user`.`account_removed` $abandon_sql",
|
||||
DBA::escape(NETWORK_DFRN),
|
||||
DBA::escape(NETWORK_OSTATUS),
|
||||
DBA::escape(NETWORK_DIASPORA),
|
||||
DBA::escape(NETWORK_FEED),
|
||||
DBA::escape(NETWORK_MAIL)
|
||||
DBA::escape(Protocol::DFRN),
|
||||
DBA::escape(Protocol::OSTATUS),
|
||||
DBA::escape(Protocol::DIASPORA),
|
||||
DBA::escape(Protocol::FEED),
|
||||
DBA::escape(Protocol::MAIL)
|
||||
);
|
||||
|
||||
if (!DBA::isResult($contacts)) {
|
||||
@@ -206,11 +207,11 @@ class Cron
|
||||
}
|
||||
|
||||
// Friendica and OStatus are checked once a day
|
||||
if (in_array($contact['network'], [NETWORK_DFRN, NETWORK_OSTATUS])) {
|
||||
if (in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS])) {
|
||||
$contact['priority'] = 2;
|
||||
}
|
||||
|
||||
if ($contact['subhub'] && in_array($contact['network'], [NETWORK_DFRN, NETWORK_OSTATUS])) {
|
||||
if ($contact['subhub'] && in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS])) {
|
||||
/*
|
||||
* We should be getting everything via a hub. But just to be sure, let's check once a day.
|
||||
* (You can make this more or less frequent if desired by setting 'pushpoll_frequency' appropriately)
|
||||
@@ -222,7 +223,7 @@ class Cron
|
||||
}
|
||||
|
||||
// Check Diaspora contacts or followers once a week
|
||||
if (($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == Contact::FOLLOWER)) {
|
||||
if (($contact["network"] == Protocol::DIASPORA) || ($contact["rel"] == Contact::FOLLOWER)) {
|
||||
$contact['priority'] = 4;
|
||||
}
|
||||
|
||||
@@ -277,7 +278,7 @@ class Cron
|
||||
}
|
||||
}
|
||||
|
||||
if (($contact['network'] == NETWORK_FEED) && ($contact['priority'] <= 3)) {
|
||||
if (($contact['network'] == Protocol::FEED) && ($contact['priority'] <= 3)) {
|
||||
$priority = PRIORITY_MEDIUM;
|
||||
} elseif ($contact['archive']) {
|
||||
$priority = PRIORITY_NEGLIGIBLE;
|
||||
|
||||
@@ -8,6 +8,7 @@ use Friendica\App;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\PostUpdate;
|
||||
use Friendica\Model\Contact;
|
||||
@@ -231,12 +232,12 @@ class CronJobs
|
||||
|
||||
$r = q("SELECT `id`, `url` FROM `contact`
|
||||
WHERE `network` = '%s' AND (`batch` = '' OR `notify` = '' OR `poll` = '' OR pubkey = '')
|
||||
ORDER BY RAND() LIMIT 50", DBA::escape(NETWORK_DIASPORA));
|
||||
ORDER BY RAND() LIMIT 50", DBA::escape(Protocol::DIASPORA));
|
||||
if (!DBA::isResult($r)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($r AS $contact) {
|
||||
foreach ($r as $contact) {
|
||||
// Quit the loop after 3 minutes
|
||||
if (time() > ($starttime + 180)) {
|
||||
return;
|
||||
@@ -247,7 +248,7 @@ class CronJobs
|
||||
}
|
||||
|
||||
$data = Probe::uri($contact["url"]);
|
||||
if ($data["network"] != NETWORK_DIASPORA) {
|
||||
if ($data["network"] != Protocol::DIASPORA) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Friendica\Worker;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
@@ -156,23 +157,23 @@ class Delivery extends BaseObject
|
||||
|
||||
// Transmit via Diaspora if the thread had started as Diaspora post
|
||||
// This is done since the uri wouldn't match (Diaspora doesn't transmit it)
|
||||
if (isset($parent) && ($parent['network'] == NETWORK_DIASPORA) && ($contact['network'] == NETWORK_DFRN)) {
|
||||
$contact['network'] = NETWORK_DIASPORA;
|
||||
if (isset($parent) && ($parent['network'] == Protocol::DIASPORA) && ($contact['network'] == Protocol::DFRN)) {
|
||||
$contact['network'] = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
logger("Delivering " . $cmd . " followup=$followup - via network " . $contact['network']);
|
||||
|
||||
switch ($contact['network']) {
|
||||
|
||||
case NETWORK_DFRN:
|
||||
case Protocol::DFRN:
|
||||
self::deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
|
||||
break;
|
||||
|
||||
case NETWORK_DIASPORA:
|
||||
case Protocol::DIASPORA:
|
||||
self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
|
||||
break;
|
||||
|
||||
case NETWORK_OSTATUS:
|
||||
case Protocol::OSTATUS:
|
||||
// Do not send to otatus if we are not configured to send to public networks
|
||||
if ($owner['prvnets']) {
|
||||
break;
|
||||
@@ -185,7 +186,7 @@ class Delivery extends BaseObject
|
||||
// This is done in "notifier.php" (See "url_recipients" and "push_notify")
|
||||
break;
|
||||
|
||||
case NETWORK_MAIL:
|
||||
case Protocol::MAIL:
|
||||
self::deliverMail($cmd, $contact, $owner, $target_item);
|
||||
break;
|
||||
|
||||
@@ -316,7 +317,7 @@ class Delivery extends BaseObject
|
||||
|
||||
if ($deliver_status < 0) {
|
||||
logger('Delivery failed: queuing message ' . $target_item["guid"] );
|
||||
Queue::add($contact['id'], NETWORK_DFRN, $atom, false, $target_item['guid']);
|
||||
Queue::add($contact['id'], Protocol::DFRN, $atom, false, $target_item['guid']);
|
||||
}
|
||||
|
||||
if (($deliver_status >= 200) && ($deliver_status <= 299)) {
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\GContact;
|
||||
@@ -147,8 +148,8 @@ class DiscoverPoCo
|
||||
WHERE `last_contact` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
|
||||
`last_failure` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
|
||||
`network` IN ('%s', '%s', '%s', '%s', '') ORDER BY rand()",
|
||||
DBA::escape(NETWORK_DFRN), DBA::escape(NETWORK_DIASPORA),
|
||||
DBA::escape(NETWORK_OSTATUS), DBA::escape(NETWORK_FEED));
|
||||
DBA::escape(Protocol::DFRN), DBA::escape(Protocol::DIASPORA),
|
||||
DBA::escape(Protocol::OSTATUS), DBA::escape(Protocol::FEED));
|
||||
|
||||
if (!$users) {
|
||||
return;
|
||||
@@ -159,13 +160,13 @@ class DiscoverPoCo
|
||||
|
||||
$urlparts = parse_url($user["url"]);
|
||||
if (!isset($urlparts["scheme"])) {
|
||||
DBA::update('gcontact', ['network' => NETWORK_PHANTOM],
|
||||
DBA::update('gcontact', ['network' => Protocol::PHANTOM],
|
||||
['nurl' => normalise_link($user["url"])]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($urlparts["host"], ["twitter.com", "identi.ca"])) {
|
||||
$networks = ["twitter.com" => NETWORK_TWITTER, "identi.ca" => NETWORK_PUMPIO];
|
||||
$networks = ["twitter.com" => Protocol::TWITTER, "identi.ca" => Protocol::PUMPIO];
|
||||
|
||||
DBA::update('gcontact', ['network' => $networks[$urlparts["host"]]],
|
||||
['nurl' => normalise_link($user["url"])]);
|
||||
@@ -182,7 +183,7 @@ class DiscoverPoCo
|
||||
$server_url = $user["server_url"];
|
||||
}
|
||||
|
||||
if ((($server_url == "") && ($user["network"] == NETWORK_FEED)) || $force_update || PortableContact::checkServer($server_url, $user["network"])) {
|
||||
if ((($server_url == "") && ($user["network"] == Protocol::FEED)) || $force_update || PortableContact::checkServer($server_url, $user["network"])) {
|
||||
logger('Check profile '.$user["url"]);
|
||||
Worker::add(PRIORITY_LOW, "DiscoverPoCo", "check_profile", $user["url"]);
|
||||
|
||||
@@ -241,7 +242,7 @@ class DiscoverPoCo
|
||||
}
|
||||
|
||||
$data = Probe::uri($jj->url);
|
||||
if ($data["network"] == NETWORK_DFRN) {
|
||||
if ($data["network"] == Protocol::DFRN) {
|
||||
logger("Profile ".$jj->url." is reachable (".$search.")", LOGGER_DEBUG);
|
||||
logger("Add profile ".$jj->url." to local directory (".$search.")", LOGGER_DEBUG);
|
||||
|
||||
@@ -288,7 +289,7 @@ class DiscoverPoCo
|
||||
/// @TODO find all those and convert to all lower-case which is a keyword then
|
||||
foreach ($contacts->data AS $user) {
|
||||
$contact = Probe::uri($user->site_address."/".$user->name);
|
||||
if ($contact["network"] != NETWORK_PHANTOM) {
|
||||
if ($contact["network"] != Protocol::PHANTOM) {
|
||||
$contact["about"] = $user->description;
|
||||
GContact::update($contact);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Network\Probe;
|
||||
@@ -31,7 +32,7 @@ class GProbe {
|
||||
|
||||
$result = Cache::get("gprobe:".$urlparts["host"]);
|
||||
if (!is_null($result)) {
|
||||
if (in_array($result["network"], [NETWORK_FEED, NETWORK_PHANTOM])) {
|
||||
if (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;
|
||||
}
|
||||
@@ -43,7 +44,7 @@ class GProbe {
|
||||
Cache::set("gprobe:".$urlparts["host"], $arr);
|
||||
}
|
||||
|
||||
if (!in_array($arr["network"], [NETWORK_FEED, NETWORK_PHANTOM])) {
|
||||
if (!in_array($arr["network"], [Protocol::FEED, Protocol::PHANTOM])) {
|
||||
GContact::update($arr);
|
||||
}
|
||||
|
||||
@@ -54,7 +55,7 @@ class GProbe {
|
||||
}
|
||||
if (DBA::isResult($r)) {
|
||||
// Check for accessibility and do a poco discovery
|
||||
if (PortableContact::lastUpdated($r[0]['url'], true) && ($r[0]["network"] == NETWORK_DFRN)) {
|
||||
if (PortableContact::lastUpdated($r[0]['url'], true) && ($r[0]["network"] == Protocol::DFRN)) {
|
||||
PortableContact::loadWorker(0, 0, $r[0]['id'], str_replace('/profile/', '/poco/', $r[0]['url']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Friendica\Worker;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
@@ -103,7 +104,7 @@ class Notifier
|
||||
$uid = $item_id;
|
||||
|
||||
$recipients_relocate = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `self` AND `network` IN ('%s', '%s')",
|
||||
intval($uid), NETWORK_DFRN, NETWORK_DIASPORA);
|
||||
intval($uid), Protocol::DFRN, Protocol::DIASPORA);
|
||||
} else {
|
||||
// find ancestors
|
||||
$condition = ['id' => $item_id, 'visible' => true, 'moderated' => false];
|
||||
@@ -250,15 +251,15 @@ class Notifier
|
||||
$target_item['deny_cid'].$target_item['deny_gid']) == 0))
|
||||
$push_notify = true;
|
||||
|
||||
if (($thr_parent && ($thr_parent['network'] == NETWORK_OSTATUS)) || ($parent['network'] == NETWORK_OSTATUS)) {
|
||||
if (($thr_parent && ($thr_parent['network'] == Protocol::OSTATUS)) || ($parent['network'] == Protocol::OSTATUS)) {
|
||||
$push_notify = true;
|
||||
|
||||
if ($parent["network"] == NETWORK_OSTATUS) {
|
||||
if ($parent["network"] == Protocol::OSTATUS) {
|
||||
// Distribute the message to the DFRN contacts as if this wasn't a followup since OStatus can't relay comments
|
||||
// Currently it is work at progress
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `network` = '%s' AND NOT `blocked` AND NOT `pending` AND NOT `archive`",
|
||||
intval($uid),
|
||||
DBA::escape(NETWORK_DFRN)
|
||||
DBA::escape(Protocol::DFRN)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
foreach ($r as $rr) {
|
||||
@@ -336,7 +337,7 @@ class Notifier
|
||||
|
||||
// If the thread parent is OStatus then do some magic to distribute the messages.
|
||||
// We have not only to look at the parent, since it could be a Friendica thread.
|
||||
if (($thr_parent && ($thr_parent['network'] == NETWORK_OSTATUS)) || ($parent['network'] == NETWORK_OSTATUS)) {
|
||||
if (($thr_parent && ($thr_parent['network'] == Protocol::OSTATUS)) || ($parent['network'] == Protocol::OSTATUS)) {
|
||||
$diaspora_delivery = false;
|
||||
|
||||
logger('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent['author-id']." - Owner: ".$thr_parent['owner-id'], LOGGER_DEBUG);
|
||||
@@ -370,9 +371,9 @@ class Notifier
|
||||
}
|
||||
|
||||
// It only makes sense to distribute answers to OStatus messages to Friendica and OStatus - but not Diaspora
|
||||
$networks = [NETWORK_OSTATUS, NETWORK_DFRN];
|
||||
$networks = [Protocol::OSTATUS, Protocol::DFRN];
|
||||
} else {
|
||||
$networks = [NETWORK_OSTATUS, NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_MAIL];
|
||||
$networks = [Protocol::OSTATUS, Protocol::DFRN, Protocol::DIASPORA, Protocol::MAIL];
|
||||
}
|
||||
} else {
|
||||
$public_message = false;
|
||||
@@ -385,7 +386,7 @@ class Notifier
|
||||
&& intval($target_item['pubmail'])) {
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `network` = '%s'",
|
||||
intval($uid),
|
||||
DBA::escape(NETWORK_MAIL)
|
||||
DBA::escape(Protocol::MAIL)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
foreach ($r as $rr) {
|
||||
@@ -440,7 +441,7 @@ class Notifier
|
||||
$r1 = q("SELECT `batch`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`name`) AS `name`, ANY_VALUE(`network`) AS `network`
|
||||
FROM `contact` WHERE `network` = '%s' AND `batch` != ''
|
||||
AND `uid` = %d AND `rel` != %d AND NOT `blocked` AND NOT `pending` AND NOT `archive` GROUP BY `batch`",
|
||||
DBA::escape(NETWORK_DIASPORA),
|
||||
DBA::escape(Protocol::DIASPORA),
|
||||
intval($owner['uid']),
|
||||
intval(Contact::SHARING)
|
||||
);
|
||||
@@ -455,7 +456,7 @@ class Notifier
|
||||
}
|
||||
}
|
||||
|
||||
$condition = ['network' => NETWORK_DFRN, 'uid' => $owner['uid'], 'blocked' => false,
|
||||
$condition = ['network' => Protocol::DFRN, 'uid' => $owner['uid'], 'blocked' => false,
|
||||
'pending' => false, 'archive' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
|
||||
|
||||
$r2 = DBA::toArray(DBA::select('contact', ['id', 'name', 'network'], $condition));
|
||||
@@ -469,7 +470,7 @@ class Notifier
|
||||
// except for Diaspora batch jobs
|
||||
// Don't deliver to folks who have already been delivered to
|
||||
|
||||
if (($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'], $conversants))) {
|
||||
if (($rr['network'] !== Protocol::DIASPORA) && (in_array($rr['id'], $conversants))) {
|
||||
logger('notifier: already delivered id=' . $rr['id']);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use Friendica\BaseObject;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
@@ -68,7 +69,7 @@ class OnePoll
|
||||
}
|
||||
|
||||
// Diaspora users, archived users and followers are only checked if they still exist.
|
||||
if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == Contact::FOLLOWER)) {
|
||||
if ($contact['archive'] || ($contact["network"] == Protocol::DIASPORA) || ($contact["rel"] == Contact::FOLLOWER)) {
|
||||
$last_updated = PortableContact::lastUpdated($contact["url"], true);
|
||||
$updated = DateTimeFormat::utcNow();
|
||||
|
||||
@@ -114,7 +115,7 @@ class OnePoll
|
||||
);
|
||||
|
||||
// Update the contact entry
|
||||
if (($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_DFRN)) {
|
||||
if (($contact['network'] === Protocol::OSTATUS) || ($contact['network'] === Protocol::DIASPORA) || ($contact['network'] === Protocol::DFRN)) {
|
||||
if (!PortableContact::reachable($contact['url'])) {
|
||||
logger("Skipping probably dead contact ".$contact['url']);
|
||||
|
||||
@@ -160,7 +161,7 @@ class OnePoll
|
||||
|
||||
logger("poll: ({$contact['network']}-{$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}");
|
||||
|
||||
if ($contact['network'] === NETWORK_DFRN) {
|
||||
if ($contact['network'] === Protocol::DFRN) {
|
||||
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
|
||||
if (intval($contact['duplex']) && $contact['dfrn-id']) {
|
||||
$idtosend = '0:' . $orig_id;
|
||||
@@ -289,9 +290,9 @@ class OnePoll
|
||||
|
||||
$xml = Network::post($contact['poll'], $postvars);
|
||||
|
||||
} elseif (($contact['network'] === NETWORK_OSTATUS)
|
||||
|| ($contact['network'] === NETWORK_DIASPORA)
|
||||
|| ($contact['network'] === NETWORK_FEED)) {
|
||||
} elseif (($contact['network'] === Protocol::OSTATUS)
|
||||
|| ($contact['network'] === Protocol::DIASPORA)
|
||||
|| ($contact['network'] === Protocol::FEED)) {
|
||||
|
||||
// Upgrading DB fields from an older Friendica version
|
||||
// Will only do this once per notify-enabled OStatus contact
|
||||
@@ -300,7 +301,7 @@ class OnePoll
|
||||
$stat_writeable = ((($contact['notify']) && ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND)) ? 1 : 0);
|
||||
|
||||
// Contacts from OStatus are always writable
|
||||
if ($contact['network'] === NETWORK_OSTATUS) {
|
||||
if ($contact['network'] === Protocol::OSTATUS) {
|
||||
$stat_writeable = 1;
|
||||
}
|
||||
|
||||
@@ -330,7 +331,7 @@ class OnePoll
|
||||
|
||||
$xml = $ret['body'];
|
||||
|
||||
} elseif ($contact['network'] === NETWORK_MAIL) {
|
||||
} elseif ($contact['network'] === Protocol::MAIL) {
|
||||
logger("Mail: Fetching for ".$contact['addr'], LOGGER_DEBUG);
|
||||
|
||||
$mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
|
||||
@@ -383,7 +384,7 @@ class OnePoll
|
||||
$datarray = [];
|
||||
$datarray['verb'] = ACTIVITY_POST;
|
||||
$datarray['object-type'] = ACTIVITY_OBJ_NOTE;
|
||||
$datarray['network'] = NETWORK_MAIL;
|
||||
$datarray['network'] = Protocol::MAIL;
|
||||
// $meta = Email::messageMeta($mbox, $msg_uid);
|
||||
|
||||
$datarray['uri'] = Email::msgid2iri(trim($meta->message_id, '<>'));
|
||||
@@ -472,7 +473,7 @@ class OnePoll
|
||||
|
||||
// If it seems to be a reply but a header couldn't be found take the last message with matching subject
|
||||
if (empty($datarray['parent-uri']) && $reply) {
|
||||
$condition = ['title' => $datarray['title'], 'uid' => importer_uid, 'network' => NETWORK_MAIL];
|
||||
$condition = ['title' => $datarray['title'], 'uid' => importer_uid, 'network' => Protocol::MAIL];
|
||||
$params = ['order' => ['created' => true]];
|
||||
$parent = Item::selectFirst(['parent-uri'], $condition, $params);
|
||||
if (DBA::isResult($parent)) {
|
||||
@@ -529,7 +530,7 @@ class OnePoll
|
||||
if ($datarray['parent-uri'] === $datarray['uri']) {
|
||||
$datarray['private'] = 1;
|
||||
}
|
||||
if (($contact['network'] === NETWORK_MAIL) && (!PConfig::get($importer_uid, 'system', 'allow_public_email_replies'))) {
|
||||
if (($contact['network'] === Protocol::MAIL) && (!PConfig::get($importer_uid, 'system', 'allow_public_email_replies'))) {
|
||||
$datarray['private'] = 1;
|
||||
$datarray['allow_cid'] = '<' . $contact['id'] . '>';
|
||||
}
|
||||
@@ -584,16 +585,16 @@ class OnePoll
|
||||
consume_feed($xml, $importer, $contact, $hub);
|
||||
|
||||
// do it a second time for DFRN so that any children find their parents.
|
||||
if ($contact['network'] === NETWORK_DFRN) {
|
||||
if ($contact['network'] === Protocol::DFRN) {
|
||||
consume_feed($xml, $importer, $contact, $hub);
|
||||
}
|
||||
|
||||
$hubmode = 'subscribe';
|
||||
if ($contact['network'] === NETWORK_DFRN || $contact['blocked']) {
|
||||
if ($contact['network'] === Protocol::DFRN || $contact['blocked']) {
|
||||
$hubmode = 'unsubscribe';
|
||||
}
|
||||
|
||||
if (($contact['network'] === NETWORK_OSTATUS || $contact['network'] == NETWORK_FEED) && (! $contact['hub-verify'])) {
|
||||
if (($contact['network'] === Protocol::OSTATUS || $contact['network'] == Protocol::FEED) && (! $contact['hub-verify'])) {
|
||||
$hub_update = true;
|
||||
}
|
||||
|
||||
@@ -603,7 +604,7 @@ class OnePoll
|
||||
|
||||
logger("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update);
|
||||
|
||||
if (strlen($hub) && $hub_update && (($contact['rel'] != Contact::FOLLOWER) || $contact['network'] == NETWORK_FEED)) {
|
||||
if (strlen($hub) && $hub_update && (($contact['rel'] != Contact::FOLLOWER) || $contact['network'] == Protocol::FEED)) {
|
||||
logger('hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
|
||||
$hubs = explode(',', $hub);
|
||||
if (count($hubs)) {
|
||||
@@ -622,7 +623,7 @@ class OnePoll
|
||||
self::updateContact($contact, ['last-update' => $updated, 'success_update' => $updated]);
|
||||
DBA::update('gcontact', ['last_contact' => $updated], ['nurl' => $contact['nurl']]);
|
||||
Contact::unmarkForArchival($contact);
|
||||
} elseif (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED])) {
|
||||
} elseif (in_array($contact["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED])) {
|
||||
$updated = DateTimeFormat::utcNow();
|
||||
|
||||
self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Friendica\Worker;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
@@ -110,7 +111,7 @@ class Queue
|
||||
$deliver_status = 0;
|
||||
|
||||
switch ($contact['network']) {
|
||||
case NETWORK_DFRN:
|
||||
case Protocol::DFRN:
|
||||
logger('queue: dfrndelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>');
|
||||
$deliver_status = DFRN::deliver($owner, $contact, $data);
|
||||
|
||||
@@ -121,7 +122,8 @@ class Queue
|
||||
Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_MINUTE);
|
||||
}
|
||||
break;
|
||||
case NETWORK_OSTATUS:
|
||||
|
||||
case Protocol::OSTATUS:
|
||||
logger('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>');
|
||||
$deliver_status = Salmon::slapper($owner, $contact['notify'], $data);
|
||||
|
||||
@@ -132,7 +134,8 @@ class Queue
|
||||
QueueModel::removeItem($q_item['id']);
|
||||
}
|
||||
break;
|
||||
case NETWORK_DIASPORA:
|
||||
|
||||
case Protocol::DIASPORA:
|
||||
logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>');
|
||||
$deliver_status = Diaspora::transmit($owner, $contact, $data, $public, true, 'Queue:' . $q_item['id'], true);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
@@ -28,13 +29,13 @@ class UpdateGContact
|
||||
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])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = Probe::uri($r[0]["url"]);
|
||||
|
||||
if (!in_array($data["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) {
|
||||
if (!in_array($data["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
|
||||
if ($r[0]["server_url"] != "") {
|
||||
PortableContact::checkServer($r[0]["server_url"], $r[0]["network"]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user