summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-03-15 11:38:37 -0700
committerBrion Vibber <brion@pobox.com>2010-03-15 11:38:37 -0700
commite9b671e3af17aaba1cbfb4dbe9e71fa4117cd0e3 (patch)
tree94c155ff660ffb1cd673399dcc96e71869c226e5
parentc4f89b06f1e7fe969e049c7dfe672bdfd6e5c8f9 (diff)
Consolidate and patch up redirection to remote notices.
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.)
-rw-r--r--actions/shownotice.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/actions/shownotice.php b/actions/shownotice.php
index d09100f67..a23027f7c 100644
--- a/actions/shownotice.php
+++ b/actions/shownotice.php
@@ -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();
}
/**