X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FOStatus%2Fscripts%2Fupdate-profile.php;h=40adda102ef8a6128c6403445abbd0f49459eed4;hb=d6b28c64830f632bb2f4b6f3c9369b9e56ad217a;hp=5b0c8b92e6af62a5f215019a3b8dba3aaee2e9b4;hpb=d9b35208ecda59292680fb55e38c56b2831d5366;p=quix0rs-gnu-social.git diff --git a/plugins/OStatus/scripts/update-profile.php b/plugins/OStatus/scripts/update-profile.php old mode 100644 new mode 100755 index 5b0c8b92e6..40adda102e --- a/plugins/OStatus/scripts/update-profile.php +++ b/plugins/OStatus/scripts/update-profile.php @@ -32,7 +32,9 @@ END_OF_HELP; require_once INSTALLDIR.'/scripts/commandline.inc.php'; -if (empty($args[0]) || !Validate::uri($args[0])) { +$validate = new Validate(); + +if (empty($args[0]) || !$validate->uri($args[0])) { print "$helptext"; exit(1); } @@ -52,12 +54,37 @@ showProfile($oprofile); print "\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 $discover = new FeedDiscovery(); -$feedurl = $discover->discoverFromURL($oprofile->uri); +try { + $feedurl = $discover->discoverFromURL($oprofile->uri); + $salmonuri = $discover->getAtomLink(Salmon::REL_SALMON) + ?: $discover->getAtomLink(Salmon::NS_REPLIES); // NS_REPLIES is deprecated + if (empty($salmonuri) ) { + throw new FeedSubNoSalmonException('No salmon upstream URI was found'); + } +} catch (FeedSubException $e) { + $acct = $oprofile->localProfile()->getAcctUri(); + print "Could not discover feeds HTML response, trying reconstructed acct URI: {$acct}\n"; + $disco = new Discovery(); + $xrd = $disco->lookup($acct); + $hints = DiscoveryHints::fromXRD($xrd); + + if (empty($feedurl) && !array_key_exists('feedurl', $hints)) { + throw new FeedSubNoFeedException($acct); + } + $feedurl = $feedurl ?: $hints['feedurl']; + $salmonuri = array_key_exists('salmon', $hints) ? $hints['salmon'] : $salmonuri; + + // get the hub data too and put it in the FeedDiscovery object + $discover->discoverFromFeedUrl($feedurl); +} + $huburi = $discover->getHubLink(); -$salmonuri = $discover->getAtomLink(Salmon::REL_SALMON) - ?: $discover->getAtomLink(Salmon::NS_REPLIES); print " Feed URL: $feedurl\n"; print " Hub URL: $huburi\n";