PortableContact created
Create PortableContact and remove socgraph, update references, and calls
This commit is contained in:
parent
47db624105
commit
259f91caa9
|
@ -8,6 +8,7 @@ use Friendica\Core\Config;
|
|||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
|
||||
function cronjobs_run(&$argv, &$argc){
|
||||
global $a;
|
||||
|
@ -17,7 +18,6 @@ function cronjobs_run(&$argv, &$argc){
|
|||
require_once 'mod/nodeinfo.php';
|
||||
require_once 'include/photos.php';
|
||||
require_once 'include/user.php';
|
||||
require_once 'include/socgraph.php';
|
||||
|
||||
// No parameter set? So return
|
||||
if ($argc <= 1) {
|
||||
|
@ -226,7 +226,7 @@ function cron_repair_diaspora(App $a) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!poco_reachable($contact["url"])) {
|
||||
if (!PortableContact::reachable($contact["url"])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ function discover_poco_run(&$argv, &$argc)
|
|||
|
||||
if ($mode == 8) {
|
||||
if ($argv[2] != "") {
|
||||
poco_last_updated($argv[2], true);
|
||||
PortableContact::lastUpdated($argv[2], true);
|
||||
}
|
||||
} elseif ($mode == 7) {
|
||||
if ($argc == 6) {
|
||||
|
@ -65,7 +65,7 @@ function discover_poco_run(&$argv, &$argc)
|
|||
}
|
||||
PortableContact::load(intval($argv[2]), intval($argv[3]), intval($argv[4]), $url);
|
||||
} elseif ($mode == 6) {
|
||||
poco_discover_single_server(intval($argv[2]));
|
||||
PortableContact::discoverSingleServer(intval($argv[2]));
|
||||
} elseif ($mode == 5) {
|
||||
update_server();
|
||||
} elseif ($mode == 4) {
|
||||
|
@ -78,7 +78,7 @@ function discover_poco_run(&$argv, &$argc)
|
|||
return;
|
||||
}
|
||||
$result = "Checking server ".$server_url." - ";
|
||||
$ret = poco_check_server($server_url);
|
||||
$ret = PortableContact::checkServer($server_url);
|
||||
if ($ret) {
|
||||
$result .= "success";
|
||||
} else {
|
||||
|
@ -94,12 +94,13 @@ function discover_poco_run(&$argv, &$argc)
|
|||
gs_search_user($search);
|
||||
} elseif (($mode == 0) && ($search == "") && (Config::get('system', 'poco_discovery') > 0)) {
|
||||
// Query Friendica and Hubzilla servers for their users
|
||||
poco_discover();
|
||||
PortableContact::discover();
|
||||
|
||||
// Query GNU Social servers for their users ("statistics" addon has to be enabled on the GS server)
|
||||
if (!Config::get('system', 'ostatus_disabled'))
|
||||
if (!Config::get('system', 'ostatus_disabled')) {
|
||||
GlobalContact::gsDiscover();
|
||||
}
|
||||
}
|
||||
|
||||
logger('end '.$search);
|
||||
|
||||
|
@ -120,7 +121,7 @@ function update_server() {
|
|||
$updated = 0;
|
||||
|
||||
foreach ($r AS $server) {
|
||||
if (!poco_do_update($server["created"], "", $server["last_failure"], $server["last_contact"])) {
|
||||
if (!PortableContact::updateNeeded($server["created"], "", $server["last_failure"], $server["last_contact"])) {
|
||||
continue;
|
||||
}
|
||||
logger('Update server status for server '.$server["url"], LOGGER_DEBUG);
|
||||
|
@ -172,7 +173,7 @@ function discover_users() {
|
|||
continue;
|
||||
}
|
||||
|
||||
$server_url = poco_detect_server($user["url"]);
|
||||
$server_url = PortableContact::detectServer($user["url"]);
|
||||
$force_update = false;
|
||||
|
||||
if ($user["server_url"] != "") {
|
||||
|
@ -182,7 +183,7 @@ function discover_users() {
|
|||
$server_url = $user["server_url"];
|
||||
}
|
||||
|
||||
if ((($server_url == "") && ($user["network"] == NETWORK_FEED)) || $force_update || poco_check_server($server_url, $user["network"])) {
|
||||
if ((($server_url == "") && ($user["network"] == NETWORK_FEED)) || $force_update || PortableContact::checkServer($server_url, $user["network"])) {
|
||||
logger('Check profile '.$user["url"]);
|
||||
Worker::add(PRIORITY_LOW, "discover_poco", "check_profile", $user["url"]);
|
||||
|
||||
|
@ -227,13 +228,13 @@ function discover_directory($search) {
|
|||
continue;
|
||||
}
|
||||
// Update the contact
|
||||
poco_last_updated($jj->url);
|
||||
PortableContact::lastUpdated($jj->url);
|
||||
continue;
|
||||
}
|
||||
|
||||
$server_url = poco_detect_server($jj->url);
|
||||
$server_url = PortableContact::detectServer($jj->url);
|
||||
if ($server_url != '') {
|
||||
if (!poco_check_server($server_url)) {
|
||||
if (!PortableContact::checkServer($server_url)) {
|
||||
logger("Friendica server ".$server_url." doesn't answer.", LOGGER_DEBUG);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file include/follow.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
|
@ -7,8 +9,8 @@ use Friendica\Core\Worker;
|
|||
use Friendica\Database\DBM;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
|
||||
require_once 'include/socgraph.php';
|
||||
require_once 'include/group.php';
|
||||
require_once 'include/salmon.php';
|
||||
require_once 'include/ostatus.php';
|
||||
|
@ -57,7 +59,7 @@ function update_contact($id) {
|
|||
);
|
||||
|
||||
// Update the corresponding gcontact entry
|
||||
poco_last_updated($ret["url"]);
|
||||
PortableContact::lastUpdated($ret["url"]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ function gprobe_run(&$argv, &$argc)
|
|||
}
|
||||
if (DBM::is_result($r)) {
|
||||
// Check for accessibility and do a poco discovery
|
||||
if (poco_last_updated($r[0]['url'], true) && ($r[0]["network"] == NETWORK_DFRN)) {
|
||||
if (PortableContact::lastUpdated($r[0]['url'], true) && ($r[0]["network"] == NETWORK_DFRN)) {
|
||||
PortableContact::loadWorker(0, 0, $r[0]['id'], str_replace('/profile/', '/poco/', $r[0]['url']));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\ParseUrl;
|
||||
use Friendica\Util\Lock;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Util\Lock;
|
||||
|
||||
require_once 'include/bbcode.php';
|
||||
require_once 'include/oembed.php';
|
||||
|
@ -25,7 +25,6 @@ require_once 'include/files.php';
|
|||
require_once 'include/text.php';
|
||||
require_once 'include/email.php';
|
||||
require_once 'include/threads.php';
|
||||
require_once 'include/socgraph.php';
|
||||
require_once 'include/plaintext.php';
|
||||
require_once 'include/ostatus.php';
|
||||
require_once 'include/feed.php';
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Network\Probe;
|
||||
|
@ -20,7 +20,6 @@ require_once 'include/bbcode.php';
|
|||
require_once 'include/items.php';
|
||||
require_once 'mod/share.php';
|
||||
require_once 'include/enotify.php';
|
||||
require_once 'include/socgraph.php';
|
||||
require_once 'include/Photo.php';
|
||||
require_once 'include/follow.php';
|
||||
require_once 'include/api.php';
|
||||
|
|
|
@ -41,7 +41,7 @@ function handle_pubsubhubbub($id) {
|
|||
|
||||
$rr = $r[0];
|
||||
|
||||
/// @todo Check server status with poco_check_server()
|
||||
/// @todo Check server status with PortableContact::checkServer()
|
||||
// Before this can be done we need a way to safely detect the server url.
|
||||
|
||||
logger("Generate feed of user ".$rr['nickname']." to ".$rr['callback_url']." - last updated ".$rr['last_update'], LOGGER_DEBUG);
|
||||
|
|
|
@ -8,12 +8,12 @@ use Friendica\Core\Worker;
|
|||
use Friendica\Database\DBM;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
|
||||
require_once 'include/queue_fn.php';
|
||||
require_once 'include/datetime.php';
|
||||
require_once 'include/items.php';
|
||||
require_once 'include/bbcode.php';
|
||||
require_once 'include/socgraph.php';
|
||||
|
||||
function queue_run(&$argv, &$argc)
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ function queue_run(&$argv, &$argc)
|
|||
return;
|
||||
}
|
||||
|
||||
$server = poco_detect_server($c[0]['url']);
|
||||
$server = PortableContact::detectServer($c[0]['url']);
|
||||
|
||||
if ($server != "") {
|
||||
$vital = Cache::get($cachekey_server.$server);
|
||||
|
@ -107,7 +107,7 @@ function queue_run(&$argv, &$argc)
|
|||
if (is_null($vital)) {
|
||||
logger("Check server ".$server." (".$c[0]["network"].")");
|
||||
|
||||
$vital = poco_check_server($server, $c[0]["network"], true);
|
||||
$vital = PortableContact::checkServer($server, $c[0]["network"], true);
|
||||
Cache::set($cachekey_server.$server, $vital, CACHE_QUARTER_HOUR);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file include/update_gcontact.php
|
||||
*/
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
|
||||
function update_gcontact_run(&$argv, &$argc) {
|
||||
global $a;
|
||||
|
||||
require_once 'include/socgraph.php';
|
||||
|
||||
logger('update_gcontact: start');
|
||||
|
||||
if (($argc > 1) && (intval($argv[1]))) {
|
||||
|
@ -34,7 +35,7 @@ function update_gcontact_run(&$argv, &$argc) {
|
|||
|
||||
if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
|
||||
if ($r[0]["server_url"] != "")
|
||||
poco_check_server($r[0]["server_url"], $r[0]["network"]);
|
||||
PortableContact::checkServer($r[0]["server_url"], $r[0]["network"]);
|
||||
|
||||
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d",
|
||||
dbesc(datetime_convert()), intval($contact_id));
|
||||
|
|
|
@ -7,7 +7,6 @@ use Friendica\Core\System;
|
|||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GlobalContact;
|
||||
|
||||
require_once 'include/socgraph.php';
|
||||
require_once 'include/Contact.php';
|
||||
require_once 'include/contact_selectors.php';
|
||||
require_once 'mod/contacts.php';
|
||||
|
|
|
@ -8,7 +8,6 @@ use Friendica\Model\GlobalContact;
|
|||
use Friendica\Network\Probe;
|
||||
|
||||
require_once 'include/Contact.php';
|
||||
require_once 'include/socgraph.php';
|
||||
require_once 'include/contact_selectors.php';
|
||||
require_once 'mod/proxy.php';
|
||||
require_once 'include/Photo.php';
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file mod/dirfind.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
|
||||
require_once 'include/contact_widgets.php';
|
||||
require_once 'include/socgraph.php';
|
||||
require_once 'include/Contact.php';
|
||||
require_once 'include/contact_selectors.php';
|
||||
require_once 'mod/contacts.php';
|
||||
|
@ -143,7 +145,7 @@ function dirfind_content(App $a, $prefix = "") {
|
|||
$j->items_page = $perpage;
|
||||
$j->page = $a->pager['page'];
|
||||
foreach ($results AS $result) {
|
||||
if (poco_alternate_ostatus_url($result["url"])) {
|
||||
if (PortableContact::alternateOStatusUrl($result["url"])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ use Friendica\App;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Model\GlobalContact;
|
||||
|
||||
require_once "include/socgraph.php";
|
||||
require_once "include/Contact.php";
|
||||
|
||||
function hovercard_init(App $a) {
|
||||
|
|
|
@ -1133,9 +1133,8 @@ function item_content(App $a) {
|
|||
*
|
||||
* @return boolean true if replaced, false if not replaced
|
||||
*/
|
||||
function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $network = "") {
|
||||
require_once 'include/socgraph.php';
|
||||
|
||||
function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $network = "")
|
||||
{
|
||||
$replaced = false;
|
||||
$r = null;
|
||||
$tag_type = '@';
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file mod/match.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
|
||||
require_once('include/text.php');
|
||||
require_once('include/socgraph.php');
|
||||
require_once('include/contact_widgets.php');
|
||||
require_once('mod/proxy.php');
|
||||
require_once 'include/text.php';
|
||||
require_once 'include/contact_widgets.php';
|
||||
require_once 'mod/proxy.php';
|
||||
|
||||
/**
|
||||
* @brief Controller for /match.
|
||||
|
@ -16,11 +17,12 @@ require_once('mod/proxy.php');
|
|||
* It takes keywords from your profile and queries the directory server for
|
||||
* matching keywords from other profiles.
|
||||
*
|
||||
* @param App $a
|
||||
* @param App $a App
|
||||
*
|
||||
* @return void|string
|
||||
*/
|
||||
function match_content(App $a) {
|
||||
|
||||
function match_content(App $a)
|
||||
{
|
||||
$o = '';
|
||||
if (! local_user()) {
|
||||
return;
|
||||
|
@ -31,7 +33,8 @@ function match_content(App $a) {
|
|||
|
||||
$_SESSION['return_url'] = System::baseUrl() . '/' . $a->cmd;
|
||||
|
||||
$r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
|
||||
$r = q(
|
||||
"SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval(local_user())
|
||||
);
|
||||
if (! DBM::is_result($r)) {
|
||||
|
@ -47,13 +50,15 @@ function match_content(App $a) {
|
|||
|
||||
if ($tags) {
|
||||
$params['s'] = $tags;
|
||||
if($a->pager['page'] != 1)
|
||||
if ($a->pager['page'] != 1) {
|
||||
$params['p'] = $a->pager['page'];
|
||||
}
|
||||
|
||||
if(strlen(Config::get('system','directory')))
|
||||
if (strlen(Config::get('system', 'directory'))) {
|
||||
$x = post_url(get_server().'/msearch', $params);
|
||||
else
|
||||
} else {
|
||||
$x = post_url(System::baseUrl() . '/msearch', $params);
|
||||
}
|
||||
|
||||
$j = json_decode($x);
|
||||
|
||||
|
@ -63,14 +68,15 @@ function match_content(App $a) {
|
|||
}
|
||||
|
||||
if (count($j->results)) {
|
||||
|
||||
$id = 0;
|
||||
|
||||
foreach ($j->results as $jj) {
|
||||
$match_nurl = normalise_link($jj->url);
|
||||
$match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
|
||||
$match = q(
|
||||
"SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
|
||||
intval(local_user()),
|
||||
dbesc($match_nurl));
|
||||
dbesc($match_nurl)
|
||||
);
|
||||
|
||||
if (!count($match)) {
|
||||
$jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
|
||||
|
@ -104,17 +110,16 @@ function match_content(App $a) {
|
|||
|
||||
$tpl = get_markup_template('viewcontact_template.tpl');
|
||||
|
||||
$o .= replace_macros($tpl,array(
|
||||
$o .= replace_macros(
|
||||
$tpl,
|
||||
array(
|
||||
'$title' => t('Profile Match'),
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => paginate($a),
|
||||
));
|
||||
|
||||
}
|
||||
else {
|
||||
'$paginate' => paginate($a))
|
||||
);
|
||||
} else {
|
||||
info(t('No matches') . EOL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file mod/nogroup.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Database\DBM;
|
||||
|
||||
require_once('include/Contact.php');
|
||||
require_once('include/socgraph.php');
|
||||
require_once('include/contact_selectors.php');
|
||||
|
||||
function nogroup_init(App $a) {
|
||||
require_once 'include/Contact.php';
|
||||
require_once 'include/contact_selectors.php';
|
||||
|
||||
function nogroup_init(App $a)
|
||||
{
|
||||
if (! local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once('include/group.php');
|
||||
require_once('include/contact_widgets.php');
|
||||
require_once 'include/group.php';
|
||||
require_once 'include/contact_widgets.php';
|
||||
|
||||
if (! x($a->page, 'aside')) {
|
||||
$a->page['aside'] = '';
|
||||
|
@ -23,15 +24,14 @@ function nogroup_init(App $a) {
|
|||
$a->page['aside'] .= group_side('contacts', 'group', 'extended', 0, $contact_id);
|
||||
}
|
||||
|
||||
|
||||
function nogroup_content(App $a) {
|
||||
|
||||
function nogroup_content(App $a)
|
||||
{
|
||||
if (! local_user()) {
|
||||
notice(t('Permission denied.') . EOL);
|
||||
return '';
|
||||
}
|
||||
|
||||
require_once('include/Contact.php');
|
||||
require_once 'include/Contact.php';
|
||||
$r = contacts_not_grouped(local_user());
|
||||
if (DBM::is_result($r)) {
|
||||
$a->set_pager_total($r[0]['total']);
|
||||
|
@ -39,7 +39,6 @@ function nogroup_content(App $a) {
|
|||
$r = contacts_not_grouped(local_user(), $a->pager['start'], $a->pager['itemspage']);
|
||||
if (DBM::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
|
||||
$contact_details = get_contact_details_by_url($rr['url'], local_user(), $rr);
|
||||
|
||||
$contacts[] = array(
|
||||
|
@ -64,12 +63,13 @@ function nogroup_content(App $a) {
|
|||
}
|
||||
|
||||
$tpl = get_markup_template("nogroup-template.tpl");
|
||||
$o .= replace_macros($tpl, array(
|
||||
$o .= replace_macros(
|
||||
$tpl,
|
||||
array(
|
||||
'$header' => t('Contacts who are not members of a group'),
|
||||
'$contacts' => $contacts,
|
||||
'$paginate' => paginate($a),
|
||||
));
|
||||
'$paginate' => paginate($a))
|
||||
);
|
||||
|
||||
return $o;
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use Friendica\App;
|
|||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
|
||||
function poco_init(App $a) {
|
||||
$system_mode = false;
|
||||
|
@ -32,9 +33,8 @@ function poco_init(App $a) {
|
|||
$global = false;
|
||||
|
||||
if ($a->argc > 1 && $a->argv[1] === '@server') {
|
||||
require_once 'include/socgraph.php';
|
||||
// List of all servers that this server knows
|
||||
$ret = poco_serverlist();
|
||||
$ret = PortableContact::serverlist();
|
||||
header('Content-type: application/json');
|
||||
echo json_encode($ret);
|
||||
killme();
|
||||
|
|
|
@ -12,7 +12,6 @@ use Friendica\Model\GlobalContact;
|
|||
use Friendica\Network\Probe;
|
||||
|
||||
require_once 'include/Contact.php';
|
||||
require_once 'include/socgraph.php';
|
||||
|
||||
function profiles_init(App $a) {
|
||||
|
||||
|
@ -755,7 +754,6 @@ function profiles_content(App $a) {
|
|||
|
||||
return $o;
|
||||
} else {
|
||||
|
||||
// If we don't support multi profiles, don't display this list.
|
||||
if (!feature_enabled(local_user(), 'multi_profiles')) {
|
||||
$r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file mod/settings.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GlobalContact;
|
||||
|
||||
require_once('include/group.php');
|
||||
require_once('include/socgraph.php');
|
||||
require_once 'include/group.php';
|
||||
|
||||
function get_theme_config_file($theme) {
|
||||
$a = get_app();
|
||||
|
|
|
@ -7,7 +7,6 @@ use Friendica\Core\System;
|
|||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GlobalContact;
|
||||
|
||||
require_once 'include/socgraph.php';
|
||||
require_once 'include/contact_widgets.php';
|
||||
|
||||
function suggest_init(App $a) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file src/Model/GlobalContact.php
|
||||
* @brief This file includes the GlobalContact class with directory related functions
|
||||
|
@ -169,7 +168,7 @@ class GlobalContact
|
|||
$gcontact['url'] = self::cleanContactUrl($gcontact['url']);
|
||||
}
|
||||
|
||||
$alternate = poco_alternate_ostatus_url($gcontact['url']);
|
||||
$alternate = PortableContact::alternateOStatusUrl($gcontact['url']);
|
||||
|
||||
// The global contacts should contain the original picture, not the cached one
|
||||
if (($gcontact['generation'] != 1) && stristr(normalise_link($gcontact['photo']), normalise_link(System::baseUrl()."/photo/"))) {
|
||||
|
@ -223,7 +222,7 @@ class GlobalContact
|
|||
}
|
||||
|
||||
if ((!isset($gcontact['network']) || !isset($gcontact['name']) || !isset($gcontact['addr']) || !isset($gcontact['photo']) || !isset($gcontact['server_url']) || $alternate)
|
||||
&& poco_reachable($gcontact['url'], $gcontact['server_url'], $gcontact['network'], false)
|
||||
&& PortableContact::reachable($gcontact['url'], $gcontact['server_url'], $gcontact['network'], false)
|
||||
) {
|
||||
$data = Probe::uri($gcontact['url']);
|
||||
|
||||
|
@ -257,7 +256,7 @@ class GlobalContact
|
|||
|
||||
if (!isset($gcontact['server_url'])) {
|
||||
// We check the server url to be sure that it is a real one
|
||||
$server_url = poco_detect_server($gcontact['url']);
|
||||
$server_url = PortableContact::detectServer($gcontact['url']);
|
||||
|
||||
// We are now sure that it is a correct URL. So we use it in the future
|
||||
if ($server_url != "") {
|
||||
|
@ -266,7 +265,7 @@ class GlobalContact
|
|||
}
|
||||
|
||||
// The server URL doesn't seem to be valid, so we don't store it.
|
||||
if (!poco_check_server($gcontact['server_url'], $gcontact['network'])) {
|
||||
if (!PortableContact::checkServer($gcontact['server_url'], $gcontact['network'])) {
|
||||
$gcontact['server_url'] = "";
|
||||
}
|
||||
|
||||
|
@ -524,7 +523,7 @@ class GlobalContact
|
|||
$j = json_decode($x);
|
||||
if ($j->entries) {
|
||||
foreach ($j->entries as $entry) {
|
||||
poco_check_server($entry->url);
|
||||
PortableContact::checkServer($entry->url);
|
||||
|
||||
$url = $entry->url . '/poco';
|
||||
if (! in_array($url, $done)) {
|
||||
|
@ -591,7 +590,7 @@ class GlobalContact
|
|||
*/
|
||||
public static function fixAlternateContactAddress(&$contact)
|
||||
{
|
||||
if (($contact["network"] == NETWORK_OSTATUS) && poco_alternate_ostatus_url($contact["url"])) {
|
||||
if (($contact["network"] == NETWORK_OSTATUS) && PortableContact::alternateOStatusUrl($contact["url"])) {
|
||||
$data = Probe::uri($contact["url"]);
|
||||
if ($contact["network"] == NETWORK_OSTATUS) {
|
||||
logger("Fix primary url from ".$contact["url"]." to ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
|
||||
|
|
|
@ -24,7 +24,6 @@ use ostatus;
|
|||
require_once "include/Contact.php";
|
||||
require_once "include/enotify.php";
|
||||
require_once "include/threads.php";
|
||||
require_once "include/socgraph.php";
|
||||
require_once "include/items.php";
|
||||
require_once "include/tags.php";
|
||||
require_once "include/files.php";
|
||||
|
|
|
@ -27,7 +27,6 @@ require_once 'include/items.php';
|
|||
require_once 'include/bb2diaspora.php';
|
||||
require_once 'include/Contact.php';
|
||||
require_once 'include/Photo.php';
|
||||
require_once 'include/socgraph.php';
|
||||
require_once 'include/group.php';
|
||||
require_once 'include/datetime.php';
|
||||
require_once 'include/queue_fn.php';
|
||||
|
|
|
@ -17,6 +17,10 @@ use Friendica\Core\Worker;
|
|||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Network\Probe;
|
||||
use dba;
|
||||
use DOMDocument;
|
||||
use DomXPath;
|
||||
use Exception;
|
||||
|
||||
require_once 'include/datetime.php';
|
||||
require_once 'include/network.php';
|
||||
|
@ -210,21 +214,21 @@ class PortableContact
|
|||
);
|
||||
}
|
||||
|
||||
function poco_reachable($profile, $server = "", $network = "", $force = false) {
|
||||
|
||||
public static function reachable($profile, $server = "", $network = "", $force = false)
|
||||
{
|
||||
if ($server == "") {
|
||||
$server = poco_detect_server($profile);
|
||||
$server = self::detectServer($profile);
|
||||
}
|
||||
|
||||
if ($server == "") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return poco_check_server($server, $network, $force);
|
||||
return self::checkServer($server, $network, $force);
|
||||
}
|
||||
|
||||
function poco_detect_server($profile) {
|
||||
|
||||
public static function detectServer($profile)
|
||||
{
|
||||
// Try to detect the server path based upon some known standard paths
|
||||
$server_url = "";
|
||||
|
||||
|
@ -283,8 +287,11 @@ class PortableContact
|
|||
return "";
|
||||
}
|
||||
|
||||
$r = q("SELECT `id` FROM `gserver` WHERE `nurl` = '%s' AND `last_contact` > `last_failure`",
|
||||
dbesc(normalise_link($server_url)));
|
||||
$r = q(
|
||||
"SELECT `id` FROM `gserver` WHERE `nurl` = '%s' AND `last_contact` > `last_failure`",
|
||||
dbesc(normalise_link($server_url))
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
return $server_url;
|
||||
}
|
||||
|
@ -298,14 +305,17 @@ class PortableContact
|
|||
return $server_url;
|
||||
}
|
||||
|
||||
function poco_alternate_ostatus_url($url) {
|
||||
public static function alternateOStatusUrl($url)
|
||||
{
|
||||
return(preg_match("=https?://.+/user/\d+=ism", $url, $matches));
|
||||
}
|
||||
|
||||
function poco_last_updated($profile, $force = false) {
|
||||
|
||||
$gcontacts = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s'",
|
||||
dbesc(normalise_link($profile)));
|
||||
public static function lastUpdated($profile, $force = false)
|
||||
{
|
||||
$gcontacts = q(
|
||||
"SELECT * FROM `gcontact` WHERE `nurl` = '%s'",
|
||||
dbesc(normalise_link($profile))
|
||||
);
|
||||
|
||||
if (!DBM::is_result($gcontacts)) {
|
||||
return false;
|
||||
|
@ -318,7 +328,7 @@ class PortableContact
|
|||
}
|
||||
|
||||
if ($force) {
|
||||
$server_url = normalise_link(poco_detect_server($profile));
|
||||
$server_url = normalise_link(self::detectServer($profile));
|
||||
}
|
||||
|
||||
if (($server_url == '') && ($gcontacts[0]["server_url"] != "")) {
|
||||
|
@ -326,7 +336,7 @@ class PortableContact
|
|||
}
|
||||
|
||||
if (!$force && (($server_url == '') || ($gcontacts[0]["server_url"] == $gcontacts[0]["nurl"]))) {
|
||||
$server_url = normalise_link(poco_detect_server($profile));
|
||||
$server_url = normalise_link(self::detectServer($profile));
|
||||
}
|
||||
|
||||
if (!in_array($gcontacts[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_FEED, NETWORK_OSTATUS, ""))) {
|
||||
|
@ -335,10 +345,13 @@ class PortableContact
|
|||
}
|
||||
|
||||
if ($server_url != "") {
|
||||
if (!poco_check_server($server_url, $gcontacts[0]["network"], $force)) {
|
||||
if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) {
|
||||
if ($force) {
|
||||
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()), dbesc(normalise_link($profile)));
|
||||
q(
|
||||
"UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(normalise_link($profile))
|
||||
);
|
||||
}
|
||||
|
||||
logger("Profile ".$profile.": Server ".$server_url." wasn't reachable.", LOGGER_DEBUG);
|
||||
|
@ -348,8 +361,10 @@ class PortableContact
|
|||
}
|
||||
|
||||
if (in_array($gcontacts[0]["network"], array("", NETWORK_FEED))) {
|
||||
$server = q("SELECT `network` FROM `gserver` WHERE `nurl` = '%s' AND `network` != ''",
|
||||
dbesc(normalise_link($server_url)));
|
||||
$server = q(
|
||||
"SELECT `network` FROM `gserver` WHERE `nurl` = '%s' AND `network` != ''",
|
||||
dbesc(normalise_link($server_url))
|
||||
);
|
||||
|
||||
if ($server) {
|
||||
$contact['network'] = $server[0]["network"];
|
||||
|
@ -360,7 +375,6 @@ class PortableContact
|
|||
|
||||
// noscrape is really fast so we don't cache the call.
|
||||
if (($server_url != "") && ($gcontacts[0]["nick"] != "")) {
|
||||
|
||||
// Use noscrape if possible
|
||||
$server = q("SELECT `noscrape`, `network` FROM `gserver` WHERE `nurl` = '%s' AND `noscrape` != ''", dbesc(normalise_link($server_url)));
|
||||
|
||||
|
@ -368,7 +382,6 @@ class PortableContact
|
|||
$noscraperet = z_fetch_url($server[0]["noscrape"]."/".$gcontacts[0]["nick"]);
|
||||
|
||||
if ($noscraperet["success"] && ($noscraperet["body"] != "")) {
|
||||
|
||||
$noscrape = json_decode($noscraperet["body"], true);
|
||||
|
||||
if (is_array($noscrape)) {
|
||||
|
@ -418,8 +431,11 @@ class PortableContact
|
|||
GlobalContact::update($contact);
|
||||
|
||||
if (trim($noscrape["updated"]) != "") {
|
||||
q("UPDATE `gcontact` SET `last_contact` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()), dbesc(normalise_link($profile)));
|
||||
q(
|
||||
"UPDATE `gcontact` SET `last_contact` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(normalise_link($profile))
|
||||
);
|
||||
|
||||
logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG);
|
||||
|
||||
|
@ -431,7 +447,7 @@ class PortableContact
|
|||
}
|
||||
|
||||
// If we only can poll the feed, then we only do this once a while
|
||||
if (!$force && !poco_do_update($gcontacts[0]["created"], $gcontacts[0]["updated"], $gcontacts[0]["last_failure"], $gcontacts[0]["last_contact"])) {
|
||||
if (!$force && !self::updateNeeded($gcontacts[0]["created"], $gcontacts[0]["updated"], $gcontacts[0]["last_failure"], $gcontacts[0]["last_contact"])) {
|
||||
logger("Profile ".$profile." was last updated at ".$gcontacts[0]["updated"]." (cached)", LOGGER_DEBUG);
|
||||
|
||||
GlobalContact::update($contact);
|
||||
|
@ -442,7 +458,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) && poco_alternate_ostatus_url($profile)
|
||||
if (($data["network"] == NETWORK_OSTATUS) && self::alternateOStatusUrl($profile)
|
||||
&& (normalise_link($profile) == normalise_link($data["alias"]))
|
||||
&& (normalise_link($profile) != normalise_link($data["url"]))
|
||||
) {
|
||||
|
@ -458,7 +474,7 @@ class PortableContact
|
|||
$gcontact = GlobalContact::sanitize($gcontact);
|
||||
GlobalContact::update($gcontact);
|
||||
|
||||
poco_last_updated($data["url"], $force);
|
||||
self::lastUpdated($data["url"], $force);
|
||||
} catch (Exception $e) {
|
||||
logger($e->getMessage(), LOGGER_DEBUG);
|
||||
}
|
||||
|
@ -468,8 +484,11 @@ class PortableContact
|
|||
}
|
||||
|
||||
if (($data["poll"] == "") || (in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM)))) {
|
||||
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()), dbesc(normalise_link($profile)));
|
||||
q(
|
||||
"UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(normalise_link($profile))
|
||||
);
|
||||
|
||||
logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG);
|
||||
return false;
|
||||
|
@ -484,8 +503,11 @@ class PortableContact
|
|||
$feedret = z_fetch_url($data["poll"]);
|
||||
|
||||
if (!$feedret["success"]) {
|
||||
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()), dbesc(normalise_link($profile)));
|
||||
q(
|
||||
"UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(normalise_link($profile))
|
||||
);
|
||||
|
||||
logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG);
|
||||
return false;
|
||||
|
@ -518,12 +540,18 @@ class PortableContact
|
|||
$last_updated = NULL_DATE;
|
||||
}
|
||||
}
|
||||
q("UPDATE `gcontact` SET `updated` = '%s', `last_contact` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(DBM::date($last_updated)), dbesc(DBM::date()), dbesc(normalise_link($profile)));
|
||||
q(
|
||||
"UPDATE `gcontact` SET `updated` = '%s', `last_contact` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(DBM::date($last_updated)),
|
||||
dbesc(DBM::date()),
|
||||
dbesc(normalise_link($profile))
|
||||
);
|
||||
|
||||
if (($gcontacts[0]["generation"] == 0)) {
|
||||
q("UPDATE `gcontact` SET `generation` = 9 WHERE `nurl` = '%s'",
|
||||
dbesc(normalise_link($profile)));
|
||||
q(
|
||||
"UPDATE `gcontact` SET `generation` = 9 WHERE `nurl` = '%s'",
|
||||
dbesc(normalise_link($profile))
|
||||
);
|
||||
}
|
||||
|
||||
logger("Profile ".$profile." was last updated at ".$last_updated, LOGGER_DEBUG);
|
||||
|
@ -531,7 +559,8 @@ class PortableContact
|
|||
return($last_updated);
|
||||
}
|
||||
|
||||
function poco_do_update($created, $updated, $last_failure, $last_contact) {
|
||||
public static function updateNeeded($created, $updated, $last_failure, $last_contact)
|
||||
{
|
||||
$now = strtotime(datetime_convert());
|
||||
|
||||
if ($updated > $last_contact) {
|
||||
|
@ -575,7 +604,8 @@ class PortableContact
|
|||
return true;
|
||||
}
|
||||
|
||||
function poco_to_boolean($val) {
|
||||
public static function toBoolean($val)
|
||||
{
|
||||
if (($val == "true") || ($val == 1)) {
|
||||
return true;
|
||||
} elseif (($val == "false") || ($val == 0)) {
|
||||
|
@ -591,7 +621,8 @@ class PortableContact
|
|||
* @param object $data POCO data
|
||||
* @return array Server data
|
||||
*/
|
||||
function poco_detect_poco_data($data) {
|
||||
public static function detectPocoData($data)
|
||||
{
|
||||
$server = false;
|
||||
|
||||
if (!isset($data->entry)) {
|
||||
|
@ -627,7 +658,8 @@ class PortableContact
|
|||
* @param string $server_url address of the server
|
||||
* @return array Server data
|
||||
*/
|
||||
function poco_fetch_nodeinfo($server_url) {
|
||||
public static function fetchNodeinfo($server_url)
|
||||
{
|
||||
$serverret = z_fetch_url($server_url."/.well-known/nodeinfo");
|
||||
if (!$serverret["success"]) {
|
||||
return false;
|
||||
|
@ -734,7 +766,8 @@ class PortableContact
|
|||
* @param string $body Front page of the server
|
||||
* @return array Server data
|
||||
*/
|
||||
function poco_detect_server_type($body) {
|
||||
public static function detectServerType($body)
|
||||
{
|
||||
$server = false;
|
||||
|
||||
$doc = new DOMDocument();
|
||||
|
@ -790,8 +823,8 @@ class PortableContact
|
|||
return $server;
|
||||
}
|
||||
|
||||
function poco_check_server($server_url, $network = "", $force = false) {
|
||||
|
||||
public static function checkServer($server_url, $network = "", $force = false)
|
||||
{
|
||||
// Unify the server address
|
||||
$server_url = trim($server_url, "/");
|
||||
$server_url = str_replace("/index.php", "", $server_url);
|
||||
|
@ -802,10 +835,12 @@ class PortableContact
|
|||
|
||||
$servers = q("SELECT * FROM `gserver` WHERE `nurl` = '%s'", dbesc(normalise_link($server_url)));
|
||||
if (DBM::is_result($servers)) {
|
||||
|
||||
if ($servers[0]["created"] <= NULL_DATE) {
|
||||
q("UPDATE `gserver` SET `created` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()), dbesc(normalise_link($server_url)));
|
||||
q(
|
||||
"UPDATE `gserver` SET `created` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(normalise_link($server_url))
|
||||
);
|
||||
}
|
||||
$poco = $servers[0]["poco"];
|
||||
$noscrape = $servers[0]["noscrape"];
|
||||
|
@ -822,7 +857,7 @@ class PortableContact
|
|||
$info = $servers[0]["info"];
|
||||
$register_policy = $servers[0]["register_policy"];
|
||||
|
||||
if (!$force && !poco_do_update($servers[0]["created"], "", $last_failure, $last_contact)) {
|
||||
if (!$force && !self::updateNeeded($servers[0]["created"], "", $last_failure, $last_contact)) {
|
||||
logger("Use cached data for server ".$server_url, LOGGER_DEBUG);
|
||||
return ($last_contact >= $last_failure);
|
||||
}
|
||||
|
@ -903,7 +938,7 @@ class PortableContact
|
|||
$data = json_decode($serverret["body"]);
|
||||
if (isset($data->totalResults)) {
|
||||
$poco = $server_url."/poco";
|
||||
$server = poco_detect_poco_data($data);
|
||||
$server = self::detectPocoData($data);
|
||||
if ($server) {
|
||||
$platform = $server['platform'];
|
||||
$network = $server['network'];
|
||||
|
@ -921,7 +956,7 @@ class PortableContact
|
|||
if (!$serverret["success"] || ($serverret["body"] == "")) {
|
||||
$failure = true;
|
||||
} else {
|
||||
$server = poco_detect_server_type($serverret["body"]);
|
||||
$server = self::detectServerType($serverret["body"]);
|
||||
if ($server) {
|
||||
$platform = $server['platform'];
|
||||
$network = $server['network'];
|
||||
|
@ -1059,9 +1094,9 @@ class PortableContact
|
|||
|
||||
$site_name = $data->site->name;
|
||||
|
||||
$data->site->closed = poco_to_boolean($data->site->closed);
|
||||
$data->site->private = poco_to_boolean($data->site->private);
|
||||
$data->site->inviteonly = poco_to_boolean($data->site->inviteonly);
|
||||
$data->site->closed = self::toBoolean($data->site->closed);
|
||||
$data->site->private = self::toBoolean($data->site->private);
|
||||
$data->site->inviteonly = self::toBoolean($data->site->inviteonly);
|
||||
|
||||
if (!$data->site->closed && !$data->site->private and $data->site->inviteonly) {
|
||||
$register_policy = REGISTER_APPROVE;
|
||||
|
@ -1109,7 +1144,7 @@ class PortableContact
|
|||
|
||||
// Query nodeinfo. Working for (at least) Diaspora and Friendica.
|
||||
if (!$failure) {
|
||||
$server = poco_fetch_nodeinfo($server_url);
|
||||
$server = self::fetchNodeinfo($server_url);
|
||||
if ($server) {
|
||||
$register_policy = $server['register_policy'];
|
||||
|
||||
|
@ -1195,7 +1230,8 @@ class PortableContact
|
|||
$platform = strip_tags($platform);
|
||||
|
||||
if ($servers) {
|
||||
q("UPDATE `gserver` SET `url` = '%s', `version` = '%s', `site_name` = '%s', `info` = '%s', `register_policy` = %d, `poco` = '%s', `noscrape` = '%s',
|
||||
q(
|
||||
"UPDATE `gserver` SET `url` = '%s', `version` = '%s', `site_name` = '%s', `info` = '%s', `register_policy` = %d, `poco` = '%s', `noscrape` = '%s',
|
||||
`network` = '%s', `platform` = '%s', `last_contact` = '%s', `last_failure` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc($server_url),
|
||||
dbesc($version),
|
||||
|
@ -1211,7 +1247,8 @@ class PortableContact
|
|||
dbesc(normalise_link($server_url))
|
||||
);
|
||||
} elseif (!$failure) {
|
||||
q("INSERT INTO `gserver` (`url`, `nurl`, `version`, `site_name`, `info`, `register_policy`, `poco`, `noscrape`, `network`, `platform`, `created`, `last_contact`, `last_failure`)
|
||||
q(
|
||||
"INSERT INTO `gserver` (`url`, `nurl`, `version`, `site_name`, `info`, `register_policy`, `poco`, `noscrape`, `network`, `platform`, `created`, `last_contact`, `last_failure`)
|
||||
VALUES ('%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
|
||||
dbesc($server_url),
|
||||
dbesc(normalise_link($server_url)),
|
||||
|
@ -1238,12 +1275,18 @@ class PortableContact
|
|||
* @brief Returns a list of all known servers
|
||||
* @return array List of server urls
|
||||
*/
|
||||
function poco_serverlist() {
|
||||
$r = q("SELECT `url`, `site_name` AS `displayName`, `network`, `platform`, `version` FROM `gserver`
|
||||
public static function serverlist()
|
||||
{
|
||||
$r = q(
|
||||
"SELECT `url`, `site_name` AS `displayName`, `network`, `platform`, `version` FROM `gserver`
|
||||
WHERE `network` IN ('%s', '%s', '%s') AND `last_contact` > `last_failure`
|
||||
ORDER BY `last_contact`
|
||||
LIMIT 1000",
|
||||
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS));
|
||||
dbesc(NETWORK_DFRN),
|
||||
dbesc(NETWORK_DIASPORA),
|
||||
dbesc(NETWORK_OSTATUS)
|
||||
);
|
||||
|
||||
if (!DBM::is_result($r)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1256,7 +1299,8 @@ class PortableContact
|
|||
*
|
||||
* @param string $poco URL to the POCO endpoint
|
||||
*/
|
||||
function poco_fetch_serverlist($poco) {
|
||||
public static function fetchServerlist($poco)
|
||||
{
|
||||
$serverret = z_fetch_url($poco."/@server");
|
||||
if (!$serverret["success"]) {
|
||||
return;
|
||||
|
@ -1278,7 +1322,8 @@ class PortableContact
|
|||
}
|
||||
}
|
||||
|
||||
function poco_discover_federation() {
|
||||
public static function discoverFederation()
|
||||
{
|
||||
$last = Config::get('poco', 'last_federation_discovery');
|
||||
|
||||
if ($last) {
|
||||
|
@ -1324,14 +1369,15 @@ class PortableContact
|
|||
// $servers = json_decode($result["body"]);
|
||||
|
||||
// foreach($servers->data as $server)
|
||||
// poco_check_server($server->instance_address);
|
||||
// self::checkServer($server->instance_address);
|
||||
// }
|
||||
//}
|
||||
|
||||
Config::set('poco', 'last_federation_discovery', time());
|
||||
}
|
||||
|
||||
function poco_discover_single_server($id) {
|
||||
public static function discoverSingleServer($id)
|
||||
{
|
||||
$r = q("SELECT `poco`, `nurl`, `url`, `network` FROM `gserver` WHERE `id` = %d", intval($id));
|
||||
if (!DBM::is_result($r)) {
|
||||
return false;
|
||||
|
@ -1340,7 +1386,7 @@ class PortableContact
|
|||
$server = $r[0];
|
||||
|
||||
// Discover new servers out there (Works from Friendica version 3.5.2)
|
||||
poco_fetch_serverlist($server["poco"]);
|
||||
self::fetchServerlist($server["poco"]);
|
||||
|
||||
// Fetch all users from the other server
|
||||
$url = $server["poco"]."/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
|
||||
|
@ -1351,10 +1397,9 @@ class PortableContact
|
|||
if ($retdata["success"]) {
|
||||
$data = json_decode($retdata["body"]);
|
||||
|
||||
poco_discover_server($data, 2);
|
||||
self::discoverServer($data, 2);
|
||||
|
||||
if (Config::get('system', 'poco_discovery') > 1) {
|
||||
|
||||
$timeframe = Config::get('system', 'poco_discovery_since');
|
||||
if ($timeframe == 0) {
|
||||
$timeframe = 30;
|
||||
|
@ -1370,12 +1415,12 @@ class PortableContact
|
|||
$retdata = z_fetch_url($url);
|
||||
if ($retdata["success"]) {
|
||||
logger("Fetch all global contacts from the server ".$server["nurl"], LOGGER_DEBUG);
|
||||
$success = poco_discover_server(json_decode($retdata["body"]));
|
||||
$success = self::discoverServer(json_decode($retdata["body"]));
|
||||
}
|
||||
|
||||
if (!$success && (Config::get('system', 'poco_discovery') > 2)) {
|
||||
logger("Fetch contacts from users of the server ".$server["nurl"], LOGGER_DEBUG);
|
||||
poco_discover_server_users($data, $server);
|
||||
self::discoverServerUsers($data, $server);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1384,7 +1429,7 @@ class PortableContact
|
|||
return true;
|
||||
} else {
|
||||
// If the server hadn't replied correctly, then force a sanity check
|
||||
poco_check_server($server["url"], $server["network"], true);
|
||||
self::checkServer($server["url"], $server["network"], true);
|
||||
|
||||
// If we couldn't reach the server, we will try it some time later
|
||||
q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(datetime_convert()), dbesc($server["nurl"]));
|
||||
|
@ -1393,10 +1438,10 @@ class PortableContact
|
|||
}
|
||||
}
|
||||
|
||||
function poco_discover($complete = false) {
|
||||
|
||||
public static function discover($complete = false)
|
||||
{
|
||||
// Update the server list
|
||||
poco_discover_federation();
|
||||
self::discoverFederation();
|
||||
|
||||
$no_of_queries = 5;
|
||||
|
||||
|
@ -1410,8 +1455,7 @@ class PortableContact
|
|||
$r = q("SELECT `id`, `url`, `network` FROM `gserver` WHERE `last_contact` >= `last_failure` AND `poco` != '' AND `last_poco_query` < '%s' ORDER BY RAND()", dbesc($last_update));
|
||||
if (DBM::is_result($r)) {
|
||||
foreach ($r as $server) {
|
||||
|
||||
if (!poco_check_server($server["url"], $server["network"])) {
|
||||
if (!self::checkServer($server["url"], $server["network"])) {
|
||||
// The server is not reachable? Okay, then we will try it later
|
||||
q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(datetime_convert()), dbesc($server["nurl"]));
|
||||
continue;
|
||||
|
@ -1427,8 +1471,8 @@ class PortableContact
|
|||
}
|
||||
}
|
||||
|
||||
function poco_discover_server_users($data, $server) {
|
||||
|
||||
public static function discoverServerUsers($data, $server)
|
||||
{
|
||||
if (!isset($data->entry)) {
|
||||
return;
|
||||
}
|
||||
|
@ -1452,14 +1496,14 @@ class PortableContact
|
|||
|
||||
$retdata = z_fetch_url($url);
|
||||
if ($retdata["success"]) {
|
||||
poco_discover_server(json_decode($retdata["body"]), 3);
|
||||
self::discoverServer(json_decode($retdata["body"]), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function poco_discover_server($data, $default_generation = 0) {
|
||||
|
||||
public static function discoverServer($data, $default_generation = 0)
|
||||
{
|
||||
if (!isset($data->entry) || !count($data->entry)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* @file src/Worker/OnePoll.php
|
||||
*/
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Config;
|
||||
|
@ -81,8 +84,8 @@ Class OnePoll
|
|||
/// @TODO Check why we don't poll the Diaspora feed at the moment (some guid problem in the items?)
|
||||
/// @TODO Check whether this is possible with Redmatrix
|
||||
if ($contact["network"] == NETWORK_DIASPORA) {
|
||||
if (poco_do_update($contact["created"], $contact["last-item"], $contact["failure_update"], $contact["success_update"])) {
|
||||
$last_updated = poco_last_updated($contact["url"]);
|
||||
if (PortableContact::updateNeeded($contact["created"], $contact["last-item"], $contact["failure_update"], $contact["success_update"])) {
|
||||
$last_updated = PortableContact::lastUpdated($contact["url"]);
|
||||
$updated = datetime_convert();
|
||||
if ($last_updated) {
|
||||
$fields = array('last-item' => $last_updated, 'last-update' => $updated, 'success_update' => $updated);
|
||||
|
@ -117,7 +120,7 @@ Class OnePoll
|
|||
|
||||
// Update the contact entry
|
||||
if (($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_DFRN)) {
|
||||
if (!poco_reachable($contact['url'])) {
|
||||
if (!PortableContact::reachable($contact['url'])) {
|
||||
logger("Skipping probably dead contact ".$contact['url']);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ use Friendica\Database\DBM;
|
|||
use Friendica\Model\GlobalContact;
|
||||
|
||||
require_once "include/plugin.php";
|
||||
require_once "include/socgraph.php";
|
||||
require_once "mod/proxy.php";
|
||||
|
||||
function vier_init(App $a) {
|
||||
|
|
Loading…
Reference in a new issue