@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make Pholio mail render without a ton of over-escaped HTML

Summary:
Ref T13202. See PHI900. Fixes T12814. Pholio currently builds HTML comments in an older way that can dump a bunch of over-escaped HTML into mail bodies.

Update the logic to be more similar to the Differential rendering logic and stop over-escaping things.

The result isn't perfect, but is dramatically less broken.

Test Plan: {F5919860}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13202, T12814

Differential Revision: https://secure.phabricator.com/D19733

+78 -41
+2 -2
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 636 636 637 637 $viewer = $this->requireActor(); 638 638 639 - $body = new PhabricatorMetaMTAMailBody(); 640 - $body->setViewer($this->requireActor()); 639 + $body = id(new PhabricatorMetaMTAMailBody()) 640 + ->setViewer($viewer); 641 641 642 642 $revision_uri = $object->getURI(); 643 643 $revision_uri = PhabricatorEnv::getProductionURI($revision_uri);
+63 -39
src/applications/pholio/editor/PholioMockEditor.php
··· 128 128 PhabricatorLiskDAO $object, 129 129 array $xactions) { 130 130 131 - $body = new PhabricatorMetaMTAMailBody(); 132 - $headers = array(); 133 - $comments = array(); 134 - $inline_comments = array(); 131 + $viewer = $this->requireActor(); 135 132 136 - foreach ($xactions as $xaction) { 137 - if ($xaction->shouldHide()) { 138 - continue; 139 - } 140 - $comment = $xaction->getComment(); 141 - switch ($xaction->getTransactionType()) { 142 - case PholioMockInlineTransaction::TRANSACTIONTYPE: 143 - if ($comment && strlen($comment->getContent())) { 144 - $inline_comments[] = $comment; 145 - } 146 - break; 147 - case PhabricatorTransactions::TYPE_COMMENT: 148 - if ($comment && strlen($comment->getContent())) { 149 - $comments[] = $comment->getContent(); 150 - } 151 - // fallthrough 152 - default: 153 - $headers[] = id(clone $xaction) 154 - ->setRenderingTarget('text') 155 - ->getTitle(); 156 - break; 157 - } 158 - } 133 + $body = id(new PhabricatorMetaMTAMailBody()) 134 + ->setViewer($viewer); 135 + 136 + $mock_uri = $object->getURI(); 137 + $mock_uri = PhabricatorEnv::getProductionURI($mock_uri); 159 138 160 - $body->addRawSection(implode("\n", $headers)); 139 + $this->addHeadersAndCommentsToMailBody( 140 + $body, 141 + $xactions, 142 + pht('View Mock'), 143 + $mock_uri); 161 144 162 - foreach ($comments as $comment) { 163 - $body->addRawSection($comment); 164 - } 145 + $type_inline = PholioMockInlineTransaction::TRANSACTIONTYPE; 165 146 166 - if ($inline_comments) { 167 - $body->addRawSection(pht('INLINE COMMENTS')); 168 - foreach ($inline_comments as $comment) { 169 - $text = pht( 170 - 'Image %d: %s', 171 - $comment->getImageID(), 172 - $comment->getContent()); 173 - $body->addRawSection($text); 147 + $inlines = array(); 148 + foreach ($xactions as $xaction) { 149 + if ($xaction->getTransactionType() == $type_inline) { 150 + $inlines[] = $xaction; 174 151 } 175 152 } 176 153 154 + $this->appendInlineCommentsForMail($object, $inlines, $body); 155 + 177 156 $body->addLinkSection( 178 157 pht('MOCK DETAIL'), 179 158 PhabricatorEnv::getProductionURI('/M'.$object->getID())); 180 159 181 160 return $body; 161 + } 162 + 163 + private function appendInlineCommentsForMail( 164 + $object, 165 + array $inlines, 166 + PhabricatorMetaMTAMailBody $body) { 167 + 168 + if (!$inlines) { 169 + return; 170 + } 171 + 172 + $viewer = $this->requireActor(); 173 + 174 + $header = pht('INLINE COMMENTS'); 175 + $body->addRawPlaintextSection($header); 176 + $body->addRawHTMLSection(phutil_tag('strong', array(), $header)); 177 + 178 + $image_ids = array(); 179 + foreach ($inlines as $inline) { 180 + $comment = $inline->getComment(); 181 + $image_id = $comment->getImageID(); 182 + $image_ids[$image_id] = $image_id; 183 + } 184 + 185 + $images = id(new PholioImageQuery()) 186 + ->setViewer($viewer) 187 + ->withIDs($image_ids) 188 + ->execute(); 189 + $images = mpull($images, null, 'getID'); 190 + 191 + foreach ($inlines as $inline) { 192 + $comment = $inline->getComment(); 193 + $content = $comment->getContent(); 194 + $image_id = $comment->getImageID(); 195 + $image = idx($images, $image_id); 196 + if ($image) { 197 + $image_name = $image->getName(); 198 + } else { 199 + $image_name = pht('Unknown (ID %d)', $image_id); 200 + } 201 + 202 + $body->addRemarkupSection( 203 + pht('Image "%s":', $image_name), 204 + $content); 205 + } 182 206 } 183 207 184 208 protected function getMailSubjectPrefix() {
+4
src/applications/pholio/storage/PholioMock.php
··· 58 58 return 'M'.$this->getID(); 59 59 } 60 60 61 + public function getURI() { 62 + return '/'.$this->getMonogram(); 63 + } 64 + 61 65 protected function getConfiguration() { 62 66 return array( 63 67 self::CONFIG_AUX_PHID => true,
+9
src/applications/pholio/storage/PholioTransaction.php
··· 53 53 return $tags; 54 54 } 55 55 56 + public function isInlineCommentTransaction() { 57 + switch ($this->getTransactionType()) { 58 + case PholioMockInlineTransaction::TRANSACTIONTYPE: 59 + return true; 60 + } 61 + 62 + return parent::isInlineCommentTransaction(); 63 + } 64 + 56 65 }