]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'direct-feed-sub' into 'master'
authormmn <mmn@hethane.se>
Mon, 14 Dec 2015 21:09:56 +0000 (21:09 +0000)
committermmn <mmn@hethane.se>
Mon, 14 Dec 2015 21:09:56 +0000 (21:09 +0000)
If we are given a direct URL to a feed, use that

See merge request !54

plugins/OStatus/actions/ostatussub.php
plugins/OStatus/classes/Ostatus_profile.php

index 6078f70b715871012e4bf010993f422201417ac4..b0c088e55d50872fb10a516a2e6a6229c0a2e574 100644 (file)
@@ -281,6 +281,10 @@ class OStatusSubAction extends Action
             // TRANS: Error text.
             $this->error = _m("Sorry, we could not reach that feed. Please try that OStatus address again later.");
             common_debug('Not a recognized feed type.', __FILE__);
+        } catch (FeedSubNoHubException $e) {
+            // TRANS: Error text.
+            $this->error = _m("Sorry, that feed is not Pubsubhubub enabled.");
+            common_debug('No hub found.', __FILE__);
         } catch (Exception $e) {
             // Any new ones we forgot about
                 // TRANS: Error message in OStatus plugin. Do not translate the domain names example.com
index 4d1c676844c51c5e9736dcc1b043a7525cbc2873..fa6170cfdf1bccd468282e8ae4e5c738e0698208 100644 (file)
@@ -635,14 +635,21 @@ class Ostatus_profile extends Managed_DataObject
             }
         }
 
-        // Try to get some hCard data
+        if (in_array(
+            preg_replace('/\s*;.*$/', '', $response->getHeader('Content-Type')),
+            array('application/rss+xml', 'application/atom+xml', 'application/xml', 'text/xml'))
+        ) {
+            $hints['feedurl'] = $response->getUrl();
+        } else {
+            // Try to get some hCard data
 
-        $body = $response->getBody();
+            $body = $response->getBody();
 
-        $hcardHints = DiscoveryHints::hcardHints($body, $finalUrl);
+            $hcardHints = DiscoveryHints::hcardHints($body, $finalUrl);
 
-        if (!empty($hcardHints)) {
-            $hints = array_merge($hints, $hcardHints);
+            if (!empty($hcardHints)) {
+                $hints = array_merge($hints, $hcardHints);
+            }
         }
 
         // Check if they've got an LRDD header