From 94dcccd1b9f97aee9e854fcbc4d6fb6b290c28a1 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 3 Sep 2015 22:16:29 +0200 Subject: [PATCH 1/5] Increase the discover timeframe --- include/socgraph.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/socgraph.php b/include/socgraph.php index 0f8afcf56d..c110d18a60 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -1259,8 +1259,8 @@ 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 + //$last_update = date("c", time() - (60 * 60 * 24)); // 24 + $last_update = date("c", time() - (60 * 60 * 24 * 7)); $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) From d9f23dbb20098db18c495cf39237662c1a6adca3 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 5 Sep 2015 04:29:37 +0200 Subject: [PATCH 2/5] New switch that restricts the search only for registered users --- mod/search.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mod/search.php b/mod/search.php index d9a2852dd4..251dd4778f 100644 --- a/mod/search.php +++ b/mod/search.php @@ -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'); From 3cccb5ecb1cd010435bfc5058159d7ac9d958dcd Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 5 Sep 2015 04:54:48 +0200 Subject: [PATCH 3/5] The repair option is added to the settings --- include/notifier.php | 10 +++++++--- mod/settings.php | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/notifier.php b/include/notifier.php index 84ed9884aa..002b3c8d74 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -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. diff --git a/mod/settings.php b/mod/settings.php index 3a07e714d0..3d1e88ebc0 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -770,6 +770,8 @@ function settings_content(&$a) { $settings_connectors .= ''.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.').''; $settings_connectors .= ''; + $settings_connectors .= '

'.t("Repair OStatus subscriptions").'

'; + /* // Deactivated by now - it doesn't seem to work reliable $legacy_contact = get_pconfig(local_user(), 'system', 'ostatus_legacy_contact'); From cecbc587291649f1e89e28dfdd9abd96f93b40ca Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 5 Sep 2015 10:32:10 +0200 Subject: [PATCH 4/5] Mass-subscribing to OStatus contacts is enabled again --- mod/ostatus_subscribe.php | 78 +++++++++++++++++++++++++++++++++++++++ mod/settings.php | 12 +++--- 2 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 mod/ostatus_subscribe.php diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php new file mode 100644 index 0000000000..c950e9700e --- /dev/null +++ b/mod/ostatus_subscribe.php @@ -0,0 +1,78 @@ +".t("Subsribing to OStatus contacts").""; + + $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'] = ''; + 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 .= "

".$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 .= "

"; + + $o .= "

".t("Keep this window open until done.")."

"; + + $a->page['htmlhead'] = ''; + + return $o; +} diff --git a/mod/settings.php b/mod/settings.php index 3d1e88ebc0..a985985c7b 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -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,18 +770,18 @@ function settings_content(&$a) { $settings_connectors .= ''.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.').''; $settings_connectors .= ''; - $settings_connectors .= '

'.t("Repair OStatus subscriptions").'

'; + $legacy_contact = get_pconfig(local_user(), 'ostatus', 'legacy_contact'); - /* - // Deactivated by now - it doesn't seem to work reliable - $legacy_contact = get_pconfig(local_user(), 'system', 'ostatus_legacy_contact'); + if ($legacy_contact != "") + $a->page['htmlhead'] = ''; $settings_connectors .= '
'; $settings_connectors .= ''; $settings_connectors .= ''; $settings_connectors .= ''.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.').''; $settings_connectors .= '
'; - */ + + $settings_connectors .= '

'.t("Repair OStatus subscriptions").'

'; $settings_connectors .= '
'; From c6d9b2da23bc43870f1665796d35c340d004a859 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 5 Sep 2015 10:54:39 +0200 Subject: [PATCH 5/5] New setting for requery days --- include/socgraph.php | 8 ++++++-- mod/admin.php | 3 +++ view/templates/admin_site.tpl | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/socgraph.php b/include/socgraph.php index c110d18a60..002623c16e 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -1259,8 +1259,12 @@ function poco_discover($complete = false) { $no_of_queries = 5; - //$last_update = date("c", time() - (60 * 60 * 24)); // 24 - $last_update = date("c", time() - (60 * 60 * 24 * 7)); + $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) diff --git a/mod/admin.php b/mod/admin.php index 0ef82d4084..d54d25a512 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -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.")), diff --git a/view/templates/admin_site.tpl b/view/templates/admin_site.tpl index b749f37cb9..b60c4f0558 100644 --- a/view/templates/admin_site.tpl +++ b/view/templates/admin_site.tpl @@ -119,6 +119,7 @@

{{$portable_contacts}}

{{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}}