Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14411933
D19105.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D19105.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 12:22 PM (10 h, 19 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6926227
Default Alt Text
D19105.diff (4 KB)
Attached To
Mode
D19105: Provide context objects for remarkup mail rendering, fixing Phriction relative URIs in initial email
Attached
Detach File
Event Timeline
Log In to Comment