refactor for multi....
This commit is contained in:
parent
f7b431d60b
commit
f30744c7c5
@ -31,21 +31,6 @@ END_OF_HELP;
|
|||||||
|
|
||||||
require_once INSTALLDIR.'/scripts/commandline.inc';
|
require_once INSTALLDIR.'/scripts/commandline.inc';
|
||||||
|
|
||||||
if (empty($args[0]) || !Validate::uri($args[0])) {
|
|
||||||
print "$helptext";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$uri = $args[0];
|
|
||||||
|
|
||||||
|
|
||||||
$oprofile = Ostatus_profile::staticGet('uri', $uri);
|
|
||||||
|
|
||||||
if (!$oprofile) {
|
|
||||||
print "No OStatus remote profile known for URI $uri\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function showProfileInfo($oprofile) {
|
function showProfileInfo($oprofile) {
|
||||||
if ($oprofile->isGroup()) {
|
if ($oprofile->isGroup()) {
|
||||||
echo "group\n";
|
echo "group\n";
|
||||||
@ -58,13 +43,21 @@ function showProfileInfo($oprofile) {
|
|||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Before:\n";
|
function fixProfile($uri) {
|
||||||
showProfileInfo($oprofile);
|
$oprofile = Ostatus_profile::staticGet('uri', $uri);
|
||||||
|
|
||||||
$feedurl = $oprofile->feeduri;
|
if (!$oprofile) {
|
||||||
$client = new HttpClient();
|
print "No OStatus remote profile known for URI $uri\n";
|
||||||
$response = $client->get($feedurl);
|
return false;
|
||||||
if ($response->isOk()) {
|
}
|
||||||
|
|
||||||
|
echo "Before:\n";
|
||||||
|
showProfileInfo($oprofile);
|
||||||
|
|
||||||
|
$feedurl = $oprofile->feeduri;
|
||||||
|
$client = new HttpClient();
|
||||||
|
$response = $client->get($feedurl);
|
||||||
|
if ($response->isOk()) {
|
||||||
echo "Updating profile from feed: $feedurl\n";
|
echo "Updating profile from feed: $feedurl\n";
|
||||||
$dom = new DOMDocument();
|
$dom = new DOMDocument();
|
||||||
if ($dom->loadXML($response->getBody())) {
|
if ($dom->loadXML($response->getBody())) {
|
||||||
@ -77,13 +70,26 @@ if ($response->isOk()) {
|
|||||||
echo " (ok)\n";
|
echo " (ok)\n";
|
||||||
} else {
|
} else {
|
||||||
echo " (no entry; skipping)\n";
|
echo " (no entry; skipping)\n";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo " (bad feed; skipping)\n";
|
echo " (bad feed; skipping)\n";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo "Failed feed fetch: {$response->getStatus()} for $feedurl\n";
|
echo "Failed feed fetch: {$response->getStatus()} for $feedurl\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "After:\n";
|
||||||
|
showProfileInfo($oprofile);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "After:\n";
|
if (empty($args[0]) || !Validate::uri($args[0])) {
|
||||||
showProfileInfo($oprofile);
|
print "$helptext";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$uri = $args[0];
|
||||||
|
fixProfile($uri);
|
||||||
|
Loading…
Reference in New Issue
Block a user