Set otherwise undiscovered salmonuri on OStatus script update-profile.php
This commit is contained in:
parent
57f26a97fb
commit
2970333adb
@ -50,6 +50,10 @@ class FeedSubNoFeedException extends FeedSubException
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FeedSubNoSalmonException extends FeedSubException
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
class FeedSubBadXmlException extends FeedSubException
|
class FeedSubBadXmlException extends FeedSubException
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -52,24 +52,31 @@ showProfile($oprofile);
|
|||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
print "Re-running feed discovery for profile URL $oprofile->uri\n";
|
print "Re-running feed discovery for profile URL $oprofile->uri\n";
|
||||||
|
|
||||||
|
$feedurl = null;
|
||||||
|
$salmonuri = null;
|
||||||
|
|
||||||
// @fixme will bork where the URI isn't the profile URL for now
|
// @fixme will bork where the URI isn't the profile URL for now
|
||||||
$discover = new FeedDiscovery();
|
$discover = new FeedDiscovery();
|
||||||
try {
|
try {
|
||||||
$feedurl = $discover->discoverFromURL($oprofile->uri);
|
$feedurl = $discover->discoverFromURL($oprofile->uri);
|
||||||
$salmonuri = $discover->getAtomLink(Salmon::REL_SALMON)
|
$salmonuri = $discover->getAtomLink(Salmon::REL_SALMON)
|
||||||
?: $discover->getAtomLink(Salmon::NS_REPLIES); // NS_REPLIES is deprecated
|
?: $discover->getAtomLink(Salmon::NS_REPLIES); // NS_REPLIES is deprecated
|
||||||
|
if (empty($salmonuri) ) {
|
||||||
|
throw new FeedSubNoSalmonException('No salmon upstream URI was found');
|
||||||
|
}
|
||||||
} catch (FeedSubException $e) {
|
} catch (FeedSubException $e) {
|
||||||
$acct = $oprofile->localProfile()->getAcctUri();
|
$acct = $oprofile->localProfile()->getAcctUri();
|
||||||
print "Could not discover feeds HTML response, trying reconstructed acct URI: " . $acct;
|
print "Could not discover feeds HTML response, trying reconstructed acct URI: {$acct}\n";
|
||||||
$disco = new Discovery();
|
$disco = new Discovery();
|
||||||
$xrd = $disco->lookup($acct);
|
$xrd = $disco->lookup($acct);
|
||||||
$hints = DiscoveryHints::fromXRD($xrd);
|
$hints = DiscoveryHints::fromXRD($xrd);
|
||||||
|
|
||||||
if (!array_key_exists('feedurl', $hints)) {
|
if (empty($feedurl) && !array_key_exists('feedurl', $hints)) {
|
||||||
throw new FeedSubNoFeedException($acct);
|
throw new FeedSubNoFeedException($acct);
|
||||||
}
|
}
|
||||||
$feedurl = $hints['feedurl'];
|
$feedurl = $feedurl ?: $hints['feedurl'];
|
||||||
$salmonuri = array_key_exists('salmon', $hints) ? $hints['salmon'] : null;
|
$salmonuri = array_key_exists('salmon', $hints) ? $hints['salmon'] : $salmonuri;
|
||||||
|
|
||||||
// get the hub data too and put it in the FeedDiscovery object
|
// get the hub data too and put it in the FeedDiscovery object
|
||||||
$discover->discoverFromFeedUrl($feedurl);
|
$discover->discoverFromFeedUrl($feedurl);
|
||||||
|
Loading…
Reference in New Issue
Block a user