Page MenuHomePhabricator

D19105.id45783.diff
No OneTemporary

D19105.id45783.diff

diff --git a/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php b/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php
--- a/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php
+++ b/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php
@@ -13,6 +13,7 @@
private $attachments = array();
private $viewer;
+ private $contextObject;
public function getViewer() {
return $this->viewer;
@@ -23,6 +24,16 @@
return $this;
}
+ public function setContextObject($context_object) {
+ $this->contextObject = $context_object;
+ return $this;
+ }
+
+ public function getContextObject() {
+ return $this->contextObject;
+ }
+
+
/* -( Composition )-------------------------------------------------------- */
@@ -45,9 +56,9 @@
public function addRemarkupSection($header, $text) {
try {
- $engine = PhabricatorMarkupEngine::newMarkupEngine(array());
- $engine->setConfig('viewer', $this->getViewer());
- $engine->setMode(PhutilRemarkupEngine::MODE_TEXT);
+ $engine = $this->newMarkupEngine()
+ ->setMode(PhutilRemarkupEngine::MODE_TEXT);
+
$styled_text = $engine->markupText($text);
$this->addPlaintextSection($header, $styled_text);
} catch (Exception $ex) {
@@ -56,12 +67,9 @@
}
try {
- $mail_engine = PhabricatorMarkupEngine::newMarkupEngine(array());
- $mail_engine->setConfig('viewer', $this->getViewer());
- $mail_engine->setMode(PhutilRemarkupEngine::MODE_HTML_MAIL);
- $mail_engine->setConfig(
- 'uri.base',
- PhabricatorEnv::getProductionURI('/'));
+ $mail_engine = $this->newMarkupEngine()
+ ->setMode(PhutilRemarkupEngine::MODE_HTML_MAIL);
+
$html = $mail_engine->markupText($text);
$this->addHTMLSection($header, $html);
} catch (Exception $ex) {
@@ -215,4 +223,19 @@
private function indent($text) {
return rtrim(" ".str_replace("\n", "\n ", $text));
}
+
+
+ private function newMarkupEngine() {
+ $engine = PhabricatorMarkupEngine::newMarkupEngine(array())
+ ->setConfig('viewer', $this->getViewer())
+ ->setConfig('uri.base', PhabricatorEnv::getProductionURI('/'));
+
+ $context = $this->getContextObject();
+ if ($context) {
+ $engine->setConfig('contextObject', $context);
+ }
+
+ return $engine;
+ }
+
}
diff --git a/src/applications/phriction/markup/PhrictionRemarkupRule.php b/src/applications/phriction/markup/PhrictionRemarkupRule.php
--- a/src/applications/phriction/markup/PhrictionRemarkupRule.php
+++ b/src/applications/phriction/markup/PhrictionRemarkupRule.php
@@ -28,17 +28,7 @@
// Handle relative links.
if ((substr($link, 0, 2) === './') || (substr($link, 0, 3) === '../')) {
- $base = null;
- $context = $this->getEngine()->getConfig('contextObject');
- if ($context !== null && $context instanceof PhrictionContent) {
- // Handle content when it's being rendered in document view.
- $base = $context->getSlug();
- }
- if ($context !== null && is_array($context) &&
- idx($context, 'phriction.isPreview')) {
- // Handle content when it's a preview for the Phriction editor.
- $base = idx($context, 'phriction.slug');
- }
+ $base = $this->getRelativeBaseURI();
if ($base !== null) {
$base_parts = explode('/', rtrim($base, '/'));
$rel_parts = explode('/', rtrim($link, '/'));
@@ -195,4 +185,30 @@
}
}
+ private function getRelativeBaseURI() {
+ $context = $this->getEngine()->getConfig('contextObject');
+
+ if (!$context) {
+ return null;
+ }
+
+ // Handle content when it's a preview for the Phriction editor.
+ if (is_array($context)) {
+ if (idx($context, 'phriction.isPreview')) {
+ return idx($context, 'phriction.slug');
+ }
+ }
+
+ if ($context instanceof PhrictionContent) {
+ return $context->getSlug();
+ }
+
+ if ($context instanceof PhrictionDocument) {
+ return $context->getSlug();
+ }
+
+ return null;
+ }
+
+
}
diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
--- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
+++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
@@ -2880,11 +2880,13 @@
PhabricatorLiskDAO $object,
array $xactions) {
- $body = new PhabricatorMetaMTAMailBody();
- $body->setViewer($this->requireActor());
+ $body = id(new PhabricatorMetaMTAMailBody())
+ ->setViewer($this->requireActor())
+ ->setContextObject($object);
$this->addHeadersAndCommentsToMailBody($body, $xactions);
$this->addCustomFieldsToMailBody($body, $object, $xactions);
+
return $body;
}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 26, 1:14 AM (10 h, 47 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6926227
Default Alt Text
D19105.id45783.diff (4 KB)

Event Timeline