mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
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
This commit is contained in:
parent
dfef8e2f07
commit
7e0249d68c
6 changed files with 134 additions and 20 deletions
|
@ -6,6 +6,10 @@ final class PhabricatorMetaMTAApplication extends PhabricatorApplication {
|
|||
return pht('MetaMTA');
|
||||
}
|
||||
|
||||
public function getBaseURI() {
|
||||
return '/mail/';
|
||||
}
|
||||
|
||||
public function getFontIcon() {
|
||||
return 'fa-send';
|
||||
}
|
||||
|
|
|
@ -4,7 +4,88 @@ final class PhabricatorMetaMTAMailViewController
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,12 +63,14 @@ final class PhabricatorMetaMTAMailQuery
|
|||
$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 @@ final class PhabricatorMetaMTAMailQuery
|
|||
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(
|
||||
|
|
|
@ -100,10 +100,21 @@ final class PhabricatorMetaMTAMailSearchEngine
|
|||
$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);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ final class PhabricatorMetaMTAMail
|
|||
public function __construct() {
|
||||
|
||||
$this->status = self::STATUS_QUEUE;
|
||||
$this->parameters = array();
|
||||
$this->parameters = array('sensitive' => true);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
@ -262,6 +262,15 @@ final class PhabricatorMetaMTAMail
|
|||
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 @@ final class PhabricatorMetaMTAMail
|
|||
// 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();
|
||||
|
||||
|
|
|
@ -2334,6 +2334,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
|||
}
|
||||
|
||||
$mail
|
||||
->setSensitiveContent(false)
|
||||
->setFrom($this->getActingAsPHID())
|
||||
->setSubjectPrefix($this->getMailSubjectPrefix())
|
||||
->setVarySubjectPrefix('['.$action.']')
|
||||
|
|
Loading…
Reference in a new issue