]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/actions/ostatustag.php
newnotice action always returns the notice's URL
[quix0rs-gnu-social.git] / plugins / OStatus / actions / ostatustag.php
index b94dec12ebffa14e0cd0d20e943d2939356aaeca..fa999fe09a759b6b4d70d3fc5173e669d764bba9 100644 (file)
@@ -38,7 +38,6 @@ class OStatusTagAction extends OStatusInitAction
         if (common_logged_in()) {
             // TRANS: Client error displayed when trying to list a local object as if it is remote.
             $this->clientError(_m('You can use the local list functionality!'));
-            return false;
         }
 
         $this->nickname = $this->trimmed('nickname');
@@ -74,7 +73,7 @@ class OStatusTagAction extends OStatusInitAction
         // TRANS: Field label.
         $this->input('profile', _m('Profile Account'), $this->profile,
                      // TRANS: Field title.
-                     _m('Your account id (for example user@identi.ca).'));
+                     _m('Your account id (for example user@example.com).'));
         $this->elementEnd('li');
         $this->elementEnd('ul');
         $this->submit('submit', $submit);
@@ -87,20 +86,18 @@ class OStatusTagAction extends OStatusInitAction
         $target_profile = $this->targetProfile();
 
         $disco = new Discovery;
-        $result = $disco->lookup($acct);
-        if (!$result) {
-            // TRANS: Client error displayed when remote profile could not be looked up.
-            $this->clientError(_m('Could not look up OStatus account profile.'));
-        }
-
-        foreach ($result->links as $link) {
-            if ($link['rel'] == 'http://ostatus.org/schema/1.0/tag') {
-                // We found a URL - let's redirect!
-                $url = Discovery::applyTemplate($link['template'], $target_profile);
-                common_log(LOG_INFO, "Sending remote subscriber $acct to $url");
-                common_redirect($url, 303);
+        $xrd = $disco->lookup($acct);
+
+        $link = $xrd->get('http://ostatus.org/schema/1.0/tag');
+        if (!is_null($link)) {
+            // We found a URL - let's redirect!
+            if (!empty($link->template)) {
+                $url = Discovery::applyTemplate($link->template, $target_profile);
+            } else {
+                $url = $link->href;
             }
-
+            common_log(LOG_INFO, "Sending remote subscriber $acct to $url");
+            common_redirect($url, 303);
         }
         // TRANS: Client error displayed when remote profile address could not be confirmed.
         $this->clientError(_m('Could not confirm remote profile address.'));