From: Michael Vogel Date: Sat, 5 Sep 2015 08:32:10 +0000 (+0200) Subject: Mass-subscribing to OStatus contacts is enabled again X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cecbc587291649f1e89e28dfdd9abd96f93b40ca;p=friendica.git Mass-subscribing to OStatus contacts is enabled again --- 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 .= '
';