From 0d6e4e2799c5099c73af7315a8d7dbea90ef42a2 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Thu, 20 Jun 2013 17:13:48 -0700 Subject: [PATCH] Pholio - render inline comments together in an email Summary: Used Differential emails as a formatting guide. This also includes "Image X: " similarly to how Differential has ": " or what have you. Fixes T3138. Test Plan: inserted some debugging code and verified the mail body format looked okay ish Reviewers: epriestley, chad Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T3138 Differential Revision: https://secure.phabricator.com/D6258 --- .../pholio/editor/PholioMockEditor.php | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/applications/pholio/editor/PholioMockEditor.php b/src/applications/pholio/editor/PholioMockEditor.php index d00d852a37..abb1075843 100644 --- a/src/applications/pholio/editor/PholioMockEditor.php +++ b/src/applications/pholio/editor/PholioMockEditor.php @@ -120,7 +120,49 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor { PhabricatorLiskDAO $object, array $xactions) { - $body = parent::buildMailBody($object, $xactions); + $body = new PhabricatorMetaMTAMailBody(); + $headers = array(); + $comments = array(); + $inline_comments = array(); + + foreach ($xactions as $xaction) { + $comment = $xaction->getComment(); + switch ($xaction->getTransactionType()) { + case PholioTransactionType::TYPE_INLINE: + if ($comment && strlen($comment->getContent())) { + $inline_comments[] = $comment; + } + break; + case PhabricatorTransactions::TYPE_COMMENT: + if ($comment && strlen($comment->getContent())) { + $comments[] = $comment->getContent(); + } + // fallthrough + default: + $headers[] = id(clone $xaction) + ->setRenderingTarget('text') + ->getTitle(); + break; + } + } + + $body->addRawSection(implode("\n", $headers)); + + foreach ($comments as $comment) { + $body->addRawSection($comment); + } + + if ($inline_comments) { + $body->addRawSection(pht('INLINE COMMENTS')); + foreach ($inline_comments as $comment) { + $text = pht( + 'Image %d: %s', + $comment->getImageID(), + $comment->getContent()); + $body->addRawSection($text); + } + } + $body->addTextSection( pht('MOCK DETAIL'), PhabricatorEnv::getProductionURI('/M'.$object->getID()));