@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.

MetaMTA - more progress to mail app

Summary:
Ref T5791. This diff adds a "sensitive" flag to `PhabricatorMetaMTAMail`, defaults it to true in the constructor, and then sets it to false in teh application transaction editor. Assumption here is that sensitive emails are basically all the emails that don't flow through the application transaction editor.

This diff also gets a basic "mail view" page up and going.

This diff also fixes a bug writing recipient edges; the actor was being included.

This bug also fixes a querying bug; we shouldn't do the automagic join of $viewer is recipient or $viewer is actor if folks are querying for recipients or actors already. The bug manifested itself as having the "inbox" be inbox + outbox.

Test Plan: viewd list of messages. viewed message detail.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5791

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

+134 -20
+4
src/applications/metamta/application/PhabricatorMetaMTAApplication.php
··· 6 6 return pht('MetaMTA'); 7 7 } 8 8 9 + public function getBaseURI() { 10 + return '/mail/'; 11 + } 12 + 9 13 public function getFontIcon() { 10 14 return 'fa-send'; 11 15 }
+82 -1
src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php
··· 4 4 extends PhabricatorMetaMTAController { 5 5 6 6 public function handleRequest(AphrontRequest $request) { 7 - // TODO 7 + $viewer = $request->getUser(); 8 + 9 + $mail = id(new PhabricatorMetaMTAMailQuery()) 10 + ->setViewer($viewer) 11 + ->withIDs(array($request->getURIData('id'))) 12 + ->executeOne(); 13 + if (!$mail) { 14 + return new Aphront404Response(); 15 + } 16 + 17 + if ($mail->hasSensitiveContent()) { 18 + $title = pht('Content Redacted'); 19 + } else { 20 + $title = $mail->getSubject(); 21 + } 22 + $header = id(new PHUIHeaderView()) 23 + ->setHeader($title) 24 + ->setUser($this->getRequest()->getUser()) 25 + ->setPolicyObject($mail); 26 + 27 + $crumbs = $this->buildApplicationCrumbs() 28 + ->addTextCrumb( 29 + 'Mail '.$mail->getID()); 30 + $object_box = id(new PHUIObjectBoxView()) 31 + ->setHeader($header) 32 + ->addPropertyList($this->buildPropertyView($mail)); 33 + 34 + return $this->buildApplicationPage( 35 + array( 36 + $crumbs, 37 + $object_box, 38 + ), 39 + array( 40 + 'title' => $title, 41 + 'pageObjects' => array($mail->getPHID()), 42 + )); 43 + } 44 + 45 + private function buildPropertyView(PhabricatorMetaMTAMail $mail) { 46 + $viewer = $this->getViewer(); 47 + 48 + $properties = id(new PHUIPropertyListView()) 49 + ->setUser($viewer) 50 + ->setObject($mail); 51 + 52 + if ($mail->getActorPHID()) { 53 + $actor_str = $viewer->renderHandle($mail->getActorPHID()); 54 + } else { 55 + $actor_str = pht('Generated by Phabricator'); 56 + } 57 + $properties->addProperty( 58 + pht('Actor'), 59 + $actor_str); 60 + 61 + if ($mail->getFrom()) { 62 + $from_str = $viewer->renderHandle($mail->getFrom()); 63 + } else { 64 + $from_str = pht('Sent by Phabricator'); 65 + } 66 + $properties->addProperty( 67 + pht('From'), 68 + $from_str); 69 + 70 + if ($mail->getToPHIDs()) { 71 + $to_list = $viewer->renderHandleList($mail->getToPHIDs()); 72 + } else { 73 + $to_list = pht('None'); 74 + } 75 + $properties->addProperty( 76 + pht('To'), 77 + $to_list); 78 + 79 + if ($mail->getCcPHIDs()) { 80 + $cc_list = $viewer->renderHandleList($mail->getCcPHIDs()); 81 + } else { 82 + $cc_list = pht('None'); 83 + } 84 + $properties->addProperty( 85 + pht('Cc'), 86 + $cc_list); 87 + 88 + return $properties; 8 89 } 9 90 10 91 }
+15 -11
src/applications/metamta/query/PhabricatorMetaMTAMailQuery.php
··· 63 63 $this->recipientPHIDs); 64 64 } 65 65 66 - $viewer = $this->getViewer(); 67 - $where[] = qsprintf( 68 - $conn_r, 69 - 'edge.dst = %s OR actorPHID = %s', 70 - $viewer->getPHID(), 71 - $viewer->getPHID()); 66 + if ($this->actorPHIDs === null && $this->recipientPHIDs === null) { 67 + $viewer = $this->getViewer(); 68 + $where[] = qsprintf( 69 + $conn_r, 70 + 'edge.dst = %s OR actorPHID = %s', 71 + $viewer->getPHID(), 72 + $viewer->getPHID()); 73 + } 72 74 73 75 $where[] = $this->buildPagingClause($conn_r); 74 76 ··· 78 80 protected function buildJoinClause(AphrontDatabaseConnection $conn) { 79 81 $joins = array(); 80 82 81 - $joins[] = qsprintf( 82 - $conn, 83 - 'LEFT JOIN %T edge ON mail.phid = edge.src AND edge.type = %d', 84 - PhabricatorEdgeConfig::TABLE_NAME_EDGE, 85 - PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST); 83 + if ($this->actorPHIDs === null && $this->recipientPHIDs === null) { 84 + $joins[] = qsprintf( 85 + $conn, 86 + 'LEFT JOIN %T edge ON mail.phid = edge.src AND edge.type = %d', 87 + PhabricatorEdgeConfig::TABLE_NAME_EDGE, 88 + PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST); 89 + } 86 90 87 91 if ($this->recipientPHIDs !== null) { 88 92 $joins[] = qsprintf(
+13 -2
src/applications/metamta/query/PhabricatorMetaMTAMailSearchEngine.php
··· 100 100 $list = new PHUIObjectItemListView(); 101 101 102 102 foreach ($mails as $mail) { 103 + if ($mail->hasSensitiveContent()) { 104 + $header = pht( 105 + 'Mail %d: < content redacted >', 106 + $mail->getID()); 107 + } else { 108 + $header = pht( 109 + 'Mail %d: %s', 110 + $mail->getID(), 111 + $mail->getSubject()); 112 + } 103 113 104 - $header = pht('Mail %d: TODO.', $mail->getID()); 105 114 $item = id(new PHUIObjectItemView()) 106 - ->setHeader($header); 115 + ->setObject($mail) 116 + ->setHeader($header) 117 + ->setHref($this->getURI('detail/'.$mail->getID())); 107 118 $list->addItem($item); 108 119 } 109 120
+19 -6
src/applications/metamta/storage/PhabricatorMetaMTAMail.php
··· 25 25 public function __construct() { 26 26 27 27 $this->status = self::STATUS_QUEUE; 28 - $this->parameters = array(); 28 + $this->parameters = array('sensitive' => true); 29 29 30 30 parent::__construct(); 31 31 } ··· 262 262 return $this; 263 263 } 264 264 265 + public function setSensitiveContent($bool) { 266 + $this->setParam('sensitive', $bool); 267 + return $this; 268 + } 269 + 270 + public function hasSensitiveContent() { 271 + return $this->getParam('sensitive', true); 272 + } 273 + 265 274 public function setHTMLBody($html) { 266 275 $this->setParam('html-body', $html); 267 276 return $this; ··· 372 381 // Write the recipient edges. 373 382 $editor = new PhabricatorEdgeEditor(); 374 383 $edge_type = PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST; 375 - $actor_phids = array_unique(array_merge( 376 - $this->getAllActorPHIDs(), 377 - $this->getExpandedRecipientPHIDs())); 378 - foreach ($actor_phids as $actor_phid) { 379 - $editor->addEdge($this->getPHID(), $edge_type, $actor_phid); 384 + $recipient_phids = array_merge( 385 + $this->getToPHIDs(), 386 + $this->getCcPHIDs()); 387 + $expanded_phids = $this->expandRecipients($recipient_phids); 388 + $all_phids = array_unique(array_merge( 389 + $recipient_phids, 390 + $expanded_phids)); 391 + foreach ($all_phids as $curr_phid) { 392 + $editor->addEdge($this->getPHID(), $edge_type, $curr_phid); 380 393 } 381 394 $editor->save(); 382 395
+1
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 2334 2334 } 2335 2335 2336 2336 $mail 2337 + ->setSensitiveContent(false) 2337 2338 ->setFrom($this->getActingAsPHID()) 2338 2339 ->setSubjectPrefix($this->getMailSubjectPrefix()) 2339 2340 ->setVarySubjectPrefix('['.$action.']')