Merge remote-tracking branch 'upstream/develop' into 1509-diaspora-import

This commit is contained in:
Michael Vogel 2015-09-06 09:15:23 +02:00
commit d20dbedddd
7 changed files with 109 additions and 10 deletions

View File

@ -295,7 +295,7 @@ function notifier_run(&$argv, &$argc){
$relay_to_owner = false;
if($relay_to_owner) {
logger('notifier: followup', LOGGER_DEBUG);
logger('notifier: followup '.$target_item["guid"], LOGGER_DEBUG);
// local followup to remote post
$followup = true;
$public_message = false; // not public
@ -331,6 +331,8 @@ function notifier_run(&$argv, &$argc){
} else {
$followup = false;
logger('Distributing directly '.$target_item["guid"], LOGGER_DEBUG);
// don't send deletions onward for other people's stuff
if($target_item['deleted'] && (! intval($target_item['wall']))) {
@ -378,7 +380,7 @@ function notifier_run(&$argv, &$argc){
}
if (count($url_recipients))
logger('notifier: url_recipients ' . print_r($url_recipients,true));
logger('notifier: '.$target_item["guid"].' url_recipients ' . print_r($url_recipients,true));
$conversants = array_unique($conversants);
@ -394,6 +396,8 @@ function notifier_run(&$argv, &$argc){
// We have not only to look at the parent, since it could be a Friendica thread.
if (($thr_parent AND ($thr_parent[0]['network'] == NETWORK_OSTATUS)) OR ($parent['network'] == NETWORK_OSTATUS)) {
logger('Some parent is OStatus for '.$target_item["guid"], LOGGER_DEBUG);
// Send a salmon notification to every person we mentioned in the post
$arr = explode(',',$target_item['tag']);
foreach($arr as $x) {
@ -650,7 +654,7 @@ function notifier_run(&$argv, &$argc){
if($contact['self'])
continue;
logger("Deliver to ".$contact['url'], LOGGER_DEBUG);
logger("Deliver ".$target_item["guid"]." to ".$contact['url'], LOGGER_DEBUG);
// potentially more than one recipient. Start a new process and space them out a bit.
// we will deliver single recipient types of message and email recipients here.

View File

@ -1259,8 +1259,12 @@ function poco_discover($complete = false) {
$no_of_queries = 5;
$last_update = date("c", time() - (60 * 60 * 6)); // 24
$last_update = date("c", time() - (60 * 60 * 24)); // 24
$requery_days = intval(get_config("system", "poco_requery_days"));
if ($requery_days == 0)
$requery_days = 7;
$last_update = date("c", time() - (60 * 60 * 24 * $requery_days));
$r = q("SELECT `poco`, `nurl`, `url`, `network` FROM `gserver` WHERE `last_contact` >= `last_failure` AND `poco` != '' AND `last_poco_query` < '%s' ORDER BY RAND()", dbesc($last_update));
if ($r)

View File

@ -387,6 +387,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_requery_days = ((x($_POST,'poco_requery_days')) ? intval(trim($_POST['poco_requery_days'])) : 7);
$poco_discovery = ((x($_POST,'poco_discovery')) ? intval(trim($_POST['poco_discovery'])) : 0);
$poco_discovery_since = ((x($_POST,'poco_discovery_since')) ? intval(trim($_POST['poco_discovery_since'])) : 30);
$poco_local_search = ((x($_POST,'poco_local_search')) ? intval(trim($_POST['poco_local_search'])) : false);
@ -462,6 +463,7 @@ function admin_page_site_post(&$a){
set_config('system','maxloadavg',$maxloadavg);
set_config('system','maxloadavg_frontend',$maxloadavg_frontend);
set_config('system','poco_completion',$poco_completion);
set_config('system','poco_requery_days',$poco_requery_days);
set_config('system','poco_discovery',$poco_discovery);
set_config('system','poco_discovery_since',$poco_discovery_since);
set_config('system','poco_local_search',$poco_local_search);
@ -744,6 +746,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("Periodical check of global contacts"), get_config('system','poco_completion'), t("If enabled, the global contacts are checked periodically for missing or outdated data and the vitality of the contacts and servers.")),
'$poco_requery_days' => array('poco_requery_days', t("Days between requery"), get_config('system','poco_requery_days'), t("Number of days after which a server is requeried for his 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 contacts. 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. The fallback increases the server load, so the recommened setting is 'Users, Global Contacts'."), $poco_discovery_choices),
'$poco_discovery_since' => array('poco_discovery_since', t("Timeframe for fetching global contacts"), (string) intval(get_config('system','poco_discovery_since')), t("When the discovery is activated, this value defines the timeframe for the activity of the global contacts that are fetched from other servers."), $poco_discovery_since_choices),
'$poco_local_search' => array('poco_local_search', t("Search the local directory"), get_config('system','poco_local_search'), t("Search the local directory instead of the global directory. When searching locally, every search will be executed on the global directory in the background. This improves the search results when the search is repeated.")),

78
mod/ostatus_subscribe.php Normal file
View File

@ -0,0 +1,78 @@
<?php
require_once('include/Scrape.php');
require_once('include/follow.php');
function ostatus_subscribe_content(&$a) {
if(! local_user()) {
notice( t('Permission denied.') . EOL);
goaway($_SESSION['return_url']);
// NOTREACHED
}
$o = "<h2>".t("Subsribing to OStatus contacts")."</h2>";
$uid = local_user();
$a = get_app();
$counter = intval($_REQUEST['counter']);
if (get_pconfig($uid, "ostatus", "legacy_friends") == "") {
if ($_REQUEST["url"] == "")
return $o.t("No contact provided.");
$contact = probe_url($_REQUEST["url"]);
if (!$contact)
return $o.t("Couldn't fetch information for contact.");
$api = $contact["baseurl"]."/api/";
// Fetching friends
$data = z_fetch_url($api."statuses/friends.json?screen_name=".$contact["nick"]);
if (!$data["success"])
return $o.t("Couldn't fetch friends for contact.");
set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]);
}
$friends = json_decode(get_pconfig($uid, "ostatus", "legacy_friends"));
$total = sizeof($friends);
if ($counter >= $total) {
$a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.$a->get_baseurl().'/settings/connectors">';
del_pconfig($uid, "ostatus", "legacy_friends");
del_pconfig($uid, "ostatus", "legacy_contact");
$o .= t("Done");
return $o;
}
$friend = $friends[$counter++];
$url = $friend->statusnet_profile_url;
$o .= "<p>".$counter."/".$total.": ".$url;
$data = probe_url($url);
if ($data["network"] == NETWORK_OSTATUS) {
$result = new_contact($uid,$url,true);
if ($result["success"])
$o .= " - ".t("success");
else
$o .= " - ".t("failed");
} else
$o .= " - ".t("ignored");
$o .= "</p>";
$o .= "<p>".t("Keep this window open until done.")."</p>";
$a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.$a->get_baseurl().'/ostatus_subscribe?counter='.$counter.'">';
return $o;
}

View File

@ -94,6 +94,13 @@ function search_content(&$a) {
return;
}
if(get_config('system','local_search') AND !local_user()) {
notice(t('Public access denied.').EOL);
return;
//http_status_exit(403);
//killme();
}
nav_set_selected('search');

View File

@ -189,7 +189,7 @@ function settings_post(&$a) {
if(x($_POST, 'general-submit')) {
set_pconfig(local_user(), 'system', 'no_intelligent_shortening', intval($_POST['no_intelligent_shortening']));
set_pconfig(local_user(), 'system', 'ostatus_autofriend', intval($_POST['snautofollow']));
//set_pconfig(local_user(), 'system', 'ostatus_legacy_contact', $_POST['legacy_contact']);
set_pconfig(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']);
} elseif(x($_POST, 'imap-submit')) {
$mail_server = ((x($_POST,'mail_server')) ? $_POST['mail_server'] : '');
@ -770,16 +770,18 @@ function settings_content(&$a) {
$settings_connectors .= '<span class="field_help">'.t('If you receive a message from an unknown OStatus user, this option decides what to do. If it is checked, a new contact will be created for every unknown user.').'</span>';
$settings_connectors .= '</div>';
/*
// Deactivated by now - it doesn't seem to work reliable
$legacy_contact = get_pconfig(local_user(), 'system', 'ostatus_legacy_contact');
$legacy_contact = get_pconfig(local_user(), 'ostatus', 'legacy_contact');
if ($legacy_contact != "")
$a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.$a->get_baseurl().'/ostatus_subscribe?url='.urlencode($legacy_contact).'">';
$settings_connectors .= '<div id="legacy-contact-wrapper" class="field input">';
$settings_connectors .= '<label id="legacy-contact-label" for="snautofollow-checkbox">'. t('Your legacy GNU Social account'). '</label>';
$settings_connectors .= '<input id="legacy-contact-checkbox" name="legacy_contact" value="'.$legacy_contact.'"/>';
$settings_connectors .= '<span class="field_help">'.t('If you enter your old GNU Social/Statusnet account name here (in the format user@domain.tld), your contacts will be added automatically. The field will be emptied when done.').'</span>';
$settings_connectors .= '</div>';
*/
$settings_connectors .= '<p><a href="'.$a->get_baseurl().'/repair_ostatus">'.t("Repair OStatus subscriptions").'</a></p>';
$settings_connectors .= '<div class="settings-submit-wrapper" ><input type="submit" name="general-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';

View File

@ -119,6 +119,7 @@
<h3>{{$portable_contacts}}</h3>
{{include file="field_checkbox.tpl" field=$poco_completion}}
{{include file="field_input.tpl" field=$poco_requery_days}}
{{include file="field_select.tpl" field=$poco_discovery}}
{{include file="field_select.tpl" field=$poco_discovery_since}}
{{include file="field_checkbox.tpl" field=$poco_local_search}}