Page MenuHomePhabricator

D13406.id32469.diff
No OneTemporary

D13406.id32469.diff

diff --git a/src/applications/metamta/application/PhabricatorMetaMTAApplication.php b/src/applications/metamta/application/PhabricatorMetaMTAApplication.php
--- a/src/applications/metamta/application/PhabricatorMetaMTAApplication.php
+++ b/src/applications/metamta/application/PhabricatorMetaMTAApplication.php
@@ -6,6 +6,10 @@
return pht('MetaMTA');
}
+ public function getBaseURI() {
+ return '/mail/';
+ }
+
public function getFontIcon() {
return 'fa-send';
}
diff --git a/src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php b/src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php
--- a/src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php
+++ b/src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php
@@ -4,7 +4,88 @@
extends PhabricatorMetaMTAController {
public function handleRequest(AphrontRequest $request) {
- // TODO
+ $viewer = $request->getUser();
+
+ $mail = id(new PhabricatorMetaMTAMailQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($request->getURIData('id')))
+ ->executeOne();
+ if (!$mail) {
+ return new Aphront404Response();
+ }
+
+ if ($mail->hasSensitiveContent()) {
+ $title = pht('Content Redacted');
+ } else {
+ $title = $mail->getSubject();
+ }
+ $header = id(new PHUIHeaderView())
+ ->setHeader($title)
+ ->setUser($this->getRequest()->getUser())
+ ->setPolicyObject($mail);
+
+ $crumbs = $this->buildApplicationCrumbs()
+ ->addTextCrumb(
+ 'Mail '.$mail->getID());
+ $object_box = id(new PHUIObjectBoxView())
+ ->setHeader($header)
+ ->addPropertyList($this->buildPropertyView($mail));
+
+ return $this->buildApplicationPage(
+ array(
+ $crumbs,
+ $object_box,
+ ),
+ array(
+ 'title' => $title,
+ 'pageObjects' => array($mail->getPHID()),
+ ));
+ }
+
+ private function buildPropertyView(PhabricatorMetaMTAMail $mail) {
+ $viewer = $this->getViewer();
+
+ $properties = id(new PHUIPropertyListView())
+ ->setUser($viewer)
+ ->setObject($mail);
+
+ if ($mail->getActorPHID()) {
+ $actor_str = $viewer->renderHandle($mail->getActorPHID());
+ } else {
+ $actor_str = pht('Generated by Phabricator');
+ }
+ $properties->addProperty(
+ pht('Actor'),
+ $actor_str);
+
+ if ($mail->getFrom()) {
+ $from_str = $viewer->renderHandle($mail->getFrom());
+ } else {
+ $from_str = pht('Sent by Phabricator');
+ }
+ $properties->addProperty(
+ pht('From'),
+ $from_str);
+
+ if ($mail->getToPHIDs()) {
+ $to_list = $viewer->renderHandleList($mail->getToPHIDs());
+ } else {
+ $to_list = pht('None');
+ }
+ $properties->addProperty(
+ pht('To'),
+ $to_list);
+
+ if ($mail->getCcPHIDs()) {
+ $cc_list = $viewer->renderHandleList($mail->getCcPHIDs());
+ } else {
+ $cc_list = pht('None');
+ }
+ $properties->addProperty(
+ pht('Cc'),
+ $cc_list);
+
+ return $properties;
}
}
diff --git a/src/applications/metamta/query/PhabricatorMetaMTAMailQuery.php b/src/applications/metamta/query/PhabricatorMetaMTAMailQuery.php
--- a/src/applications/metamta/query/PhabricatorMetaMTAMailQuery.php
+++ b/src/applications/metamta/query/PhabricatorMetaMTAMailQuery.php
@@ -63,12 +63,14 @@
$this->recipientPHIDs);
}
- $viewer = $this->getViewer();
- $where[] = qsprintf(
- $conn_r,
- 'edge.dst = %s OR actorPHID = %s',
- $viewer->getPHID(),
- $viewer->getPHID());
+ if ($this->actorPHIDs === null && $this->recipientPHIDs === null) {
+ $viewer = $this->getViewer();
+ $where[] = qsprintf(
+ $conn_r,
+ 'edge.dst = %s OR actorPHID = %s',
+ $viewer->getPHID(),
+ $viewer->getPHID());
+ }
$where[] = $this->buildPagingClause($conn_r);
@@ -78,11 +80,13 @@
protected function buildJoinClause(AphrontDatabaseConnection $conn) {
$joins = array();
- $joins[] = qsprintf(
- $conn,
- 'LEFT JOIN %T edge ON mail.phid = edge.src AND edge.type = %d',
- PhabricatorEdgeConfig::TABLE_NAME_EDGE,
- PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST);
+ if ($this->actorPHIDs === null && $this->recipientPHIDs === null) {
+ $joins[] = qsprintf(
+ $conn,
+ 'LEFT JOIN %T edge ON mail.phid = edge.src AND edge.type = %d',
+ PhabricatorEdgeConfig::TABLE_NAME_EDGE,
+ PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST);
+ }
if ($this->recipientPHIDs !== null) {
$joins[] = qsprintf(
diff --git a/src/applications/metamta/query/PhabricatorMetaMTAMailSearchEngine.php b/src/applications/metamta/query/PhabricatorMetaMTAMailSearchEngine.php
--- a/src/applications/metamta/query/PhabricatorMetaMTAMailSearchEngine.php
+++ b/src/applications/metamta/query/PhabricatorMetaMTAMailSearchEngine.php
@@ -100,10 +100,21 @@
$list = new PHUIObjectItemListView();
foreach ($mails as $mail) {
+ if ($mail->hasSensitiveContent()) {
+ $header = pht(
+ 'Mail %d: < content redacted >',
+ $mail->getID());
+ } else {
+ $header = pht(
+ 'Mail %d: %s',
+ $mail->getID(),
+ $mail->getSubject());
+ }
- $header = pht('Mail %d: TODO.', $mail->getID());
$item = id(new PHUIObjectItemView())
- ->setHeader($header);
+ ->setObject($mail)
+ ->setHeader($header)
+ ->setHref($this->getURI('detail/'.$mail->getID()));
$list->addItem($item);
}
diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php
--- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php
+++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php
@@ -25,7 +25,7 @@
public function __construct() {
$this->status = self::STATUS_QUEUE;
- $this->parameters = array();
+ $this->parameters = array('sensitive' => true);
parent::__construct();
}
@@ -262,6 +262,15 @@
return $this;
}
+ public function setSensitiveContent($bool) {
+ $this->setParam('sensitive', $bool);
+ return $this;
+ }
+
+ public function hasSensitiveContent() {
+ return $this->getParam('sensitive', true);
+ }
+
public function setHTMLBody($html) {
$this->setParam('html-body', $html);
return $this;
@@ -372,11 +381,15 @@
// Write the recipient edges.
$editor = new PhabricatorEdgeEditor();
$edge_type = PhabricatorMetaMTAMailHasRecipientEdgeType::EDGECONST;
- $actor_phids = array_unique(array_merge(
- $this->getAllActorPHIDs(),
- $this->getExpandedRecipientPHIDs()));
- foreach ($actor_phids as $actor_phid) {
- $editor->addEdge($this->getPHID(), $edge_type, $actor_phid);
+ $recipient_phids = array_merge(
+ $this->getToPHIDs(),
+ $this->getCcPHIDs());
+ $expanded_phids = $this->expandRecipients($recipient_phids);
+ $all_phids = array_unique(array_merge(
+ $recipient_phids,
+ $expanded_phids));
+ foreach ($all_phids as $curr_phid) {
+ $editor->addEdge($this->getPHID(), $edge_type, $curr_phid);
}
$editor->save();
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
@@ -2334,6 +2334,7 @@
}
$mail
+ ->setSensitiveContent(false)
->setFrom($this->getActingAsPHID())
->setSubjectPrefix($this->getMailSubjectPrefix())
->setVarySubjectPrefix('['.$action.']')

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 13, 9:55 AM (5 d, 9 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6722071
Default Alt Text
D13406.id32469.diff (7 KB)

Event Timeline