mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
When marking up Phurl URLs for mail, use absolute URLs
Summary: Fixes T10625. Test Plan: Faked this locallly and it looked OK, I'll check the mail in production. :3333 Reviewers: chad Reviewed By: chad Maniphest Tasks: T10625 Differential Revision: https://secure.phabricator.com/D15497
This commit is contained in:
parent
01885cad1c
commit
981f3a9068
1 changed files with 28 additions and 27 deletions
|
@ -18,7 +18,9 @@ final class PhabricatorPhurlLinkRemarkupRule extends PhutilRemarkupRule {
|
||||||
public function markupLink(array $matches) {
|
public function markupLink(array $matches) {
|
||||||
$engine = $this->getEngine();
|
$engine = $this->getEngine();
|
||||||
$viewer = $engine->getConfig('viewer');
|
$viewer = $engine->getConfig('viewer');
|
||||||
|
|
||||||
$text_mode = $engine->isTextMode();
|
$text_mode = $engine->isTextMode();
|
||||||
|
$html_mode = $engine->isHTMLMailMode();
|
||||||
|
|
||||||
if (!$this->isFlatText($matches[0])) {
|
if (!$this->isFlatText($matches[0])) {
|
||||||
return $matches[0];
|
return $matches[0];
|
||||||
|
@ -28,46 +30,45 @@ final class PhabricatorPhurlLinkRemarkupRule extends PhutilRemarkupRule {
|
||||||
$monogram = null;
|
$monogram = null;
|
||||||
$is_monogram = '/^U(?P<id>[1-9]\d*)/';
|
$is_monogram = '/^U(?P<id>[1-9]\d*)/';
|
||||||
|
|
||||||
|
$query = id(new PhabricatorPhurlURLQuery())
|
||||||
|
->setViewer($viewer);
|
||||||
|
|
||||||
if (preg_match($is_monogram, $ref, $monogram)) {
|
if (preg_match($is_monogram, $ref, $monogram)) {
|
||||||
$phurls = id(new PhabricatorPhurlURLQuery())
|
$query->withIDs(array($monogram[1]));
|
||||||
->setViewer($viewer)
|
|
||||||
->withIDs(array($monogram[1]))
|
|
||||||
->execute();
|
|
||||||
} else if (ctype_digit($ref)) {
|
} else if (ctype_digit($ref)) {
|
||||||
$phurls = id(new PhabricatorPhurlURLQuery())
|
$query->withIDs(array($ref));
|
||||||
->setViewer($viewer)
|
|
||||||
->withIDs(array($ref))
|
|
||||||
->execute();
|
|
||||||
} else {
|
} else {
|
||||||
$phurls = id(new PhabricatorPhurlURLQuery())
|
$query->withAliases(array($ref));
|
||||||
->setViewer($viewer)
|
|
||||||
->withAliases(array($ref))
|
|
||||||
->execute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$phurl = head($phurls);
|
$phurl = $query->executeOne();
|
||||||
|
if (!$phurl) {
|
||||||
|
return $matches[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
$uri = $phurl->getRedirectURI();
|
||||||
|
$name = $phurl->getDisplayName();
|
||||||
|
|
||||||
|
if ($text_mode || $html_mode) {
|
||||||
|
$uri = PhabricatorEnv::getProductionURI($uri);
|
||||||
|
}
|
||||||
|
|
||||||
if ($phurl) {
|
|
||||||
if ($text_mode) {
|
if ($text_mode) {
|
||||||
return $phurl->getDisplayName().
|
return pht(
|
||||||
' <'.
|
'%s <%s>',
|
||||||
$phurl->getRedirectURI().
|
$name,
|
||||||
'>';
|
$uri);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
$link = phutil_tag(
|
$link = phutil_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'href' => $phurl->getRedirectURI(),
|
'href' => $uri,
|
||||||
'target' => '_blank',
|
'target' => '_blank',
|
||||||
),
|
),
|
||||||
$phurl->getDisplayName());
|
$name);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->getEngine()->storeText($link);
|
return $this->getEngine()->storeText($link);
|
||||||
} else {
|
|
||||||
return $matches[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue