@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
at upstream/main 83 lines 2.5 kB view raw
1<?php 2 3final class PhabricatorApplicationTransactionCommentRawController 4 extends PhabricatorApplicationTransactionController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $viewer = $this->getViewer(); 8 $phid = $request->getURIData('phid'); 9 10 $xaction = id(new PhabricatorObjectQuery()) 11 ->withPHIDs(array($phid)) 12 ->setViewer($viewer) 13 ->executeOne(); 14 15 if (!$xaction) { 16 return new Aphront404Response(); 17 } 18 19 if (!$xaction->getComment()) { 20 // You can't view a raw comment if there is no comment. 21 return new Aphront404Response(); 22 } 23 24 if ($xaction->getComment()->getIsRemoved()) { 25 // You can't view a raw comment if the comment is deleted. 26 return new Aphront400Response(); 27 } 28 29 $obj_phid = $xaction->getObjectPHID(); 30 $obj_handle = id(new PhabricatorHandleQuery()) 31 ->setViewer($viewer) 32 ->withPHIDs(array($obj_phid)) 33 ->executeOne(); 34 35 $title = pht('Raw Comment'); 36 $body = $xaction->getComment()->getContent(); 37 $addendum = null; 38 if ($request->getExists('email')) { 39 $content_source = $xaction->getContentSource(); 40 $source_email = PhabricatorEmailContentSource::SOURCECONST; 41 if ($content_source->getSource() == $source_email) { 42 $source_id = $content_source->getContentSourceParameter('id'); 43 if ($source_id) { 44 $message = id(new PhabricatorMetaMTAReceivedMail())->loadOneWhere( 45 'id = %d', 46 $source_id); 47 if ($message) { 48 $title = pht('Email Body Text'); 49 $body = $message->getRawTextBody(); 50 $details_text = pht( 51 'For full details, run `/bin/mail show-inbound --id %d`', 52 $source_id); 53 $addendum = new PHUIRemarkupView($viewer, $details_text); 54 } 55 } 56 } 57 } 58 $dialog = id(new AphrontDialogView()) 59 ->setUser($viewer) 60 ->addCancelButton($obj_handle->getURI()) 61 ->setTitle($title); 62 63 $dialog 64 ->addHiddenInput('anchor', $request->getStr('anchor')) 65 ->appendChild( 66 id(new PHUIFormLayoutView()) 67 ->setFullWidth(true) 68 ->appendChild( 69 id(new AphrontFormTextAreaControl()) 70 ->setReadOnly(true) 71 ->setValue($body))); 72 if ($addendum) { 73 $dialog->appendParagraph($addendum); 74 } 75 76 return id(new AphrontDialogResponse())->setDialog($dialog); 77 } 78 79 public function shouldAllowPublic() { 80 return true; 81 } 82 83}