Option to discover contacts from remote users (fallback option)
This commit is contained in:
parent
e47c65eb13
commit
2a5fb7b175
|
@ -57,7 +57,7 @@ function discover_poco_run(&$argv, &$argc){
|
|||
|
||||
logger('start');
|
||||
|
||||
if (get_config('system','poco_discovery'))
|
||||
if (get_config('system','poco_discovery') > 0)
|
||||
poco_discover();
|
||||
|
||||
logger('end');
|
||||
|
|
|
@ -970,7 +970,7 @@ function update_suggestions() {
|
|||
}
|
||||
}
|
||||
|
||||
function poco_discover() {
|
||||
function poco_discover($complete = false) {
|
||||
|
||||
$last_update = date("c", time() - (60 * 60 * 24));
|
||||
|
||||
|
@ -980,25 +980,64 @@ function poco_discover() {
|
|||
// Fetch all users from the other server
|
||||
$url = $server["poco"]."/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,generation";
|
||||
|
||||
logger("Fetch all users from the server ".$server["nurl"], LOGGER_DEBUG);
|
||||
|
||||
$retdata = z_fetch_url($url);
|
||||
if ($retdata["success"]) {
|
||||
poco_discover_server(json_decode($retdata["body"]), 2);
|
||||
$data = json_decode($retdata["body"]);
|
||||
poco_discover_server($data, 2);
|
||||
|
||||
// Fetch all global contacts from the other server (Not working with Redmatrix and Friendica versions before 3.3)
|
||||
$url = $server["poco"]."/@global?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,generation";
|
||||
if (get_config('system','poco_discovery') > 1) {
|
||||
|
||||
$retdata = z_fetch_url($url);
|
||||
if ($retdata["success"])
|
||||
poco_discover_server(json_decode($retdata["body"]));
|
||||
// Fetch all global contacts from the other server (Not working with Redmatrix and Friendica versions before 3.3)
|
||||
$url = $server["poco"]."/@global?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,generation";
|
||||
|
||||
$retdata = z_fetch_url($url);
|
||||
if ($retdata["success"]) {
|
||||
logger("Fetch all global contacts from the server ".$server["nurl"], LOGGER_DEBUG);
|
||||
poco_discover_server(json_decode($retdata["body"]));
|
||||
} elseif (get_config('system','poco_discovery') > 2) {
|
||||
logger("Fetch contacts from users of the server ".$server["nurl"], LOGGER_DEBUG);
|
||||
poco_discover_server_users($data);
|
||||
}
|
||||
}
|
||||
|
||||
q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(datetime_convert()), dbesc($server["nurl"]));
|
||||
break;
|
||||
if (!$complete)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function poco_discover_server_users($data) {
|
||||
foreach ($data->entry AS $entry) {
|
||||
$username = "";
|
||||
if (isset($entry->urls)) {
|
||||
foreach($entry->urls as $url)
|
||||
if($url->type == 'profile') {
|
||||
$profile_url = $url->value;
|
||||
$urlparts = parse_url($profile_url);
|
||||
$username = end(explode("/", $urlparts["path"]));
|
||||
}
|
||||
}
|
||||
if ($username != "") {
|
||||
logger("Fetch contacts for the user ".$username." from the server ".$server["nurl"], LOGGER_DEBUG);
|
||||
|
||||
// Fetch all contacts from a given user from the other server
|
||||
$url = $server["poco"]."/".$username."/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,generation";
|
||||
|
||||
$retdata = z_fetch_url($url);
|
||||
if ($retdata["success"])
|
||||
poco_discover_server(json_decode($retdata["body"]), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function poco_discover_server($data, $default_generation = 0) {
|
||||
|
||||
if (!isset($data->entry) OR !count($data->entry))
|
||||
return;
|
||||
|
||||
foreach ($data->entry AS $entry) {
|
||||
$profile_url = '';
|
||||
$profile_photo = '';
|
||||
|
@ -1057,8 +1096,11 @@ function poco_discover_server($data, $default_generation = 0) {
|
|||
foreach($entry->tags as $tag)
|
||||
$keywords = implode(", ", $tag);
|
||||
|
||||
if ($generation > 0)
|
||||
if ($generation > 0) {
|
||||
logger("Store profile ".$profile_url, LOGGER_DEBUG);
|
||||
poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $generation);
|
||||
logger("Done for profile ".$profile_url, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -359,7 +359,7 @@ function admin_page_site_post(&$a){
|
|||
$maxloadavg = ((x($_POST,'maxloadavg')) ? intval(trim($_POST['maxloadavg'])) : 50);
|
||||
$maxloadavg_frontend = ((x($_POST,'maxloadavg_frontend')) ? intval(trim($_POST['maxloadavg_frontend'])) : 50);
|
||||
$poco_completion = ((x($_POST,'poco_completion')) ? intval(trim($_POST['poco_completion'])) : false);
|
||||
$poco_discovery = ((x($_POST,'poco_discovery')) ? intval(trim($_POST['poco_discovery'])) : false);
|
||||
$poco_discovery = ((x($_POST,'poco_discovery')) ? intval(trim($_POST['poco_discovery'])) : 0);
|
||||
$dfrn_only = ((x($_POST,'dfrn_only')) ? True : False);
|
||||
$ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False);
|
||||
$ostatus_poll_interval = ((x($_POST,'ostatus_poll_interval')) ? intval(trim($_POST['ostatus_poll_interval'])) : 0);
|
||||
|
@ -382,8 +382,8 @@ function admin_page_site_post(&$a){
|
|||
$old_pager = ((x($_POST,'old_pager')) ? True : False);
|
||||
$only_tag_search = ((x($_POST,'only_tag_search')) ? True : False);
|
||||
$rino = ((x($_POST,'rino')) ? intval($_POST['rino']) : 0);
|
||||
|
||||
|
||||
|
||||
|
||||
if($ssl_policy != intval(get_config('system','ssl_policy'))) {
|
||||
if($ssl_policy == SSL_POLICY_FULL) {
|
||||
q("update `contact` set
|
||||
|
@ -586,6 +586,13 @@ function admin_page_site(&$a) {
|
|||
"1440" => t("Daily")
|
||||
);
|
||||
|
||||
$poco_discovery_choices = array(
|
||||
"0" => t("Disabled"),
|
||||
"1" => t("Users"),
|
||||
"2" => t("Users, Global Contacts"),
|
||||
"3" => t("Users, Global Contacts/fallback"),
|
||||
);
|
||||
|
||||
/* get user names to make the install a personal install of X */
|
||||
$user_names = array();
|
||||
$user_names['---'] = t('Multi user instance');
|
||||
|
@ -693,7 +700,7 @@ function admin_page_site(&$a) {
|
|||
'$maxloadavg_frontend' => array('maxloadavg_frontend', t("Maximum Load Average (Frontend)"), ((intval(get_config('system','maxloadavg_frontend')) > 0)?get_config('system','maxloadavg_frontend'):50), t("Maximum system load before the frontend quits service - default 50.")),
|
||||
|
||||
'$poco_completion' => array('poco_completion', t("Completion of incoming contacts"), get_config('system','poco_completion'), t("Complete data of incomplete incoming contacts that are provided by the 'portable contacts' functionality. (Useful for poco exchange with Redmatrix and friendica servers before 3.3)")),
|
||||
'$poco_discovery' => array('poco_discovery', t("Discover contacts from other servers"), get_config('system','poco_discovery'), t("Periodically query other friendica servers for their recent contacts.")),
|
||||
'$poco_discovery' => array('poco_discovery', t("Discover contacts from other servers"), (string) intval(get_config('system','poco_discovery')), t("Periodically query other servers for profiles. You can choose between 'users': the users on the remote system, 'Global Contacts': active contacts that are known on the system. The fallback is meant for Redmatrix servers and older friendica servers, where global contacts weren't available."), $poco_discovery_choices),
|
||||
|
||||
'$use_fulltext_engine' => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system','use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")),
|
||||
'$suppress_language' => array('suppress_language', t("Suppress Language"), get_config('system','suppress_language'), t("Suppress language information in meta information about a posting.")),
|
||||
|
|
|
@ -117,7 +117,7 @@
|
|||
|
||||
<h3>{{$portable_contacts}}</h3>
|
||||
{{include file="field_checkbox.tpl" field=$poco_completion}}
|
||||
{{include file="field_checkbox.tpl" field=$poco_discovery}}
|
||||
{{include file="field_select.tpl" field=$poco_discovery}}
|
||||
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
|
||||
|
||||
<h3>{{$performance}}</h3>
|
||||
|
|
Loading…
Reference in New Issue
Block a user