diff options
author | Brion Vibber <brion@pobox.com> | 2010-02-08 14:06:36 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-02-08 14:58:12 -0800 |
commit | 384387c9b05aefb438f5dbe7e272b1f234ede172 (patch) | |
tree | 7ac5935467b748c98782800846165b864a3588f7 /plugins/OStatus/lib/feeddiscovery.php | |
parent | dc09453a77f33c4dfdff306321ce93cf5fbd2d57 (diff) |
OStatus cleanup...
* Treat linkless feed posts as status updates; drop the "New post:" prefix and quotes on them.
* Use stable user IDs for atom/rss2 feed links instead of unstable nicknames
* Pull Atom feed preferentially when subscribing -- can now put the remote user's profile page straight into the feed subscription form and get to the right place.
* Clean up naming for push endpoints
Diffstat (limited to 'plugins/OStatus/lib/feeddiscovery.php')
-rw-r--r-- | plugins/OStatus/lib/feeddiscovery.php | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/plugins/OStatus/lib/feeddiscovery.php b/plugins/OStatus/lib/feeddiscovery.php index 9bc7892fb..39985fc90 100644 --- a/plugins/OStatus/lib/feeddiscovery.php +++ b/plugins/OStatus/lib/feeddiscovery.php @@ -168,7 +168,13 @@ class FeedDiscovery } // Ok... now on to the links! + // Types listed in order of priority -- we'll prefer Atom if available. // @fixme merge with the munger link checks + $feeds = array( + 'application/atom+xml' => false, + 'application/rss+xml' => false, + ); + $nodes = $dom->getElementsByTagName('link'); for ($i = 0; $i < $nodes->length; $i++) { $node = $nodes->item($i); @@ -181,17 +187,21 @@ class FeedDiscovery $type = trim($type->value); $href = trim($href->value); - $feedTypes = array( - 'application/rss+xml', - 'application/atom+xml', - ); - if (trim($rel) == 'alternate' && in_array($type, $feedTypes)) { - return $this->resolveURI($href, $base); + if (trim($rel) == 'alternate' && array_key_exists($type, $feeds) && empty($feeds[$type])) { + // Save the first feed found of each type... + $feeds[$type] = $this->resolveURI($href, $base); } } } } + // Return the highest-priority feed found + foreach ($feeds as $type => $url) { + if ($url) { + return $url; + } + } + return false; } |