]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Consolidate and patch up redirection to remote notices.
authorBrion Vibber <brion@pobox.com>
Mon, 15 Mar 2010 18:38:37 +0000 (11:38 -0700)
committerBrion Vibber <brion@pobox.com>
Mon, 15 Mar 2010 18:38:37 +0000 (11:38 -0700)
Now using the correct order consistently (URL, then URI if http/s), and as a niceness measure skipping the redirect if the only URL we have stored is the local one. (Could happen if remote OStatus feed has tag URIs and no alt link.)

actions/shownotice.php

index d09100f676aaf473e46e54aadd409f6ff1b1eb0c..a23027f7c5f6858f308008c647c9e21fe576691e 100644 (file)
@@ -103,11 +103,6 @@ class ShownoticeAction extends OwnerDesignAction
 
         $this->user = User::staticGet('id', $this->profile->id);
 
-        if ($this->notice->is_local == Notice::REMOTE_OMB) {
-            common_redirect($this->notice->uri);
-            return false;
-        }
-
         $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
 
         return true;
@@ -198,13 +193,20 @@ class ShownoticeAction extends OwnerDesignAction
 
         if ($this->notice->is_local == Notice::REMOTE_OMB) {
             if (!empty($this->notice->url)) {
-                common_redirect($this->notice->url, 301);
+                $target = $this->notice->url;
             } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) {
-                common_redirect($this->notice->uri, 301);
+                // Old OMB posts saved the remote URL only into the URI field.
+                $target = $this->notice->uri;
+            } else {
+                // Shouldn't happen.
+                $target = false;
+            }
+            if ($target && $target != $this->selfUrl()) {
+                common_redirect($target, 301);
+                return false;
             }
-        } else {
-            $this->showPage();
         }
+        $this->showPage();
     }
 
     /**