1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 07:50:57 +01:00

Move the inbound mail list to the CLI

Summary: Same as D6419. See D6413.

Test Plan:
      13  epriestley        D6                    Re: [local/Differential] [Request, 83 lines] D6: aabd
      14  epriestley        D6                    Re: [local/Differential] [Request, 83 lines] D6: aabd
      15  -                 -                     Re: [local/Diffusion] [Commit] rGTEST8fc313c77729: derp
      16  -                 -                     Re: [local/Diffusion] [Commit] rGTEST8fc313c77729: derp
      17  -                 -                     Re: [local/Diffusion] [Commit] rGTEST8fc313c77729: derp
      18  -                 -                     Re: [local/Diffusion] [Commit] rGTEST8fc313c77729: derp
      19  -                 -                     Re: [local/Diffusion] [Commit] rGTEST8fc313c77729: derp
      20  -                 -                     (No subject.)
      21  epriestley        D22                   (No subject.)
      22  epriestley        D12                   (No subject.)

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6420
This commit is contained in:
epriestley 2013-07-10 15:18:37 -07:00
parent 6bac7e390e
commit e8f679fa88
6 changed files with 66 additions and 85 deletions

View file

@ -21,6 +21,7 @@ $workflows = array(
new PhabricatorMailManagementShowInboundWorkflow(),
new PhabricatorMailManagementSendTestWorkflow(),
new PhabricatorMailManagementReceiveTestWorkflow(),
new PhabricatorMailManagementListInboundWorkflow(),
);
$args->parseWorkflows($workflows);

View file

@ -1211,6 +1211,7 @@ phutil_register_library_map(array(
'PhabricatorMailImplementationPHPMailerLiteAdapter' => 'applications/metamta/adapter/PhabricatorMailImplementationPHPMailerLiteAdapter.php',
'PhabricatorMailImplementationSendGridAdapter' => 'applications/metamta/adapter/PhabricatorMailImplementationSendGridAdapter.php',
'PhabricatorMailImplementationTestAdapter' => 'applications/metamta/adapter/PhabricatorMailImplementationTestAdapter.php',
'PhabricatorMailManagementListInboundWorkflow' => 'applications/metamta/management/PhabricatorMailManagementListInboundWorkflow.php',
'PhabricatorMailManagementReceiveTestWorkflow' => 'applications/metamta/management/PhabricatorMailManagementReceiveTestWorkflow.php',
'PhabricatorMailManagementResendWorkflow' => 'applications/metamta/management/PhabricatorMailManagementResendWorkflow.php',
'PhabricatorMailManagementSendTestWorkflow' => 'applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php',
@ -1248,7 +1249,6 @@ phutil_register_library_map(array(
'PhabricatorMetaMTAMailBodyTestCase' => 'applications/metamta/view/__tests__/PhabricatorMetaMTAMailBodyTestCase.php',
'PhabricatorMetaMTAMailTestCase' => 'applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php',
'PhabricatorMetaMTAMailingList' => 'applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php',
'PhabricatorMetaMTAReceivedListController' => 'applications/metamta/controller/PhabricatorMetaMTAReceivedListController.php',
'PhabricatorMetaMTAReceivedMail' => 'applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php',
'PhabricatorMetaMTAReceivedMailProcessingException' => 'applications/metamta/exception/PhabricatorMetaMTAReceivedMailProcessingException.php',
'PhabricatorMetaMTAReceivedMailTestCase' => 'applications/metamta/storage/__tests__/PhabricatorMetaMTAReceivedMailTestCase.php',
@ -3168,6 +3168,7 @@ phutil_register_library_map(array(
'PhabricatorMailImplementationPHPMailerLiteAdapter' => 'PhabricatorMailImplementationAdapter',
'PhabricatorMailImplementationSendGridAdapter' => 'PhabricatorMailImplementationAdapter',
'PhabricatorMailImplementationTestAdapter' => 'PhabricatorMailImplementationAdapter',
'PhabricatorMailManagementListInboundWorkflow' => 'PhabricatorSearchManagementWorkflow',
'PhabricatorMailManagementReceiveTestWorkflow' => 'PhabricatorSearchManagementWorkflow',
'PhabricatorMailManagementResendWorkflow' => 'PhabricatorSearchManagementWorkflow',
'PhabricatorMailManagementSendTestWorkflow' => 'PhabricatorSearchManagementWorkflow',
@ -3196,7 +3197,6 @@ phutil_register_library_map(array(
'PhabricatorMetaMTAMailBodyTestCase' => 'PhabricatorTestCase',
'PhabricatorMetaMTAMailTestCase' => 'PhabricatorTestCase',
'PhabricatorMetaMTAMailingList' => 'PhabricatorMetaMTADAO',
'PhabricatorMetaMTAReceivedListController' => 'PhabricatorMetaMTAController',
'PhabricatorMetaMTAReceivedMail' => 'PhabricatorMetaMTADAO',
'PhabricatorMetaMTAReceivedMailProcessingException' => 'Exception',
'PhabricatorMetaMTAReceivedMailTestCase' => 'PhabricatorTestCase',

View file

@ -31,7 +31,6 @@ final class PhabricatorApplicationMetaMTA extends PhabricatorApplication {
$this->getBaseURI() => array(
'' => 'PhabricatorMetaMTAListController',
'view/(?P<id>[1-9]\d*)/' => 'PhabricatorMetaMTAViewController',
'received/' => 'PhabricatorMetaMTAReceivedListController',
'sendgrid/' => 'PhabricatorMetaMTASendGridReceiveController',
),
);

View file

@ -12,7 +12,6 @@ abstract class PhabricatorMetaMTAController extends PhabricatorController {
$nav->addLabel(pht('Mail Logs'));
$nav->addFilter('sent', pht('Sent Mail'), $this->getApplicationURI());
$nav->addFilter('received', pht('Received Mail'));
return $nav;
}

View file

@ -1,81 +0,0 @@
<?php
final class PhabricatorMetaMTAReceivedListController
extends PhabricatorMetaMTAController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$pager = new AphrontPagerView();
$pager->setOffset($request->getInt('page'));
$pager->setURI($request->getRequestURI(), 'page');
$mails = id(new PhabricatorMetaMTAReceivedMail())->loadAllWhere(
'1 = 1 ORDER BY id DESC LIMIT %d, %d',
$pager->getOffset(),
$pager->getPageSize() + 1);
$mails = $pager->sliceResults($mails);
$phids = array_merge(
mpull($mails, 'getAuthorPHID'),
mpull($mails, 'getRelatedPHID'));
$phids = array_unique(array_filter($phids));
$handles = $this->loadViewerHandles($phids);
$rows = array();
foreach ($mails as $mail) {
$rows[] = array(
$mail->getID(),
phabricator_date($mail->getDateCreated(), $user),
phabricator_time($mail->getDateCreated(), $user),
$mail->getAuthorPHID()
? $handles[$mail->getAuthorPHID()]->renderLink()
: '-',
$mail->getRelatedPHID()
? $handles[$mail->getRelatedPHID()]->renderLink()
: '-',
$mail->getMessage(),
);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
pht('ID'),
pht('Date'),
pht('Time'),
pht('Author'),
pht('Object'),
pht('Message'),
));
$table->setColumnClasses(
array(
null,
null,
'right',
null,
null,
'wide',
));
$panel = new AphrontPanelView();
$panel->setHeader(pht('Received Mail'));
$panel->appendChild($table);
$panel->appendChild($pager);
$panel->setNoBackground();
$nav = $this->buildSideNavView();
$nav->selectFilter('received');
$nav->appendChild($panel);
return $this->buildApplicationPage(
$nav,
array(
'title' => pht('Received Mail'),
'device' => true,
));
}
}

View file

@ -0,0 +1,63 @@
<?php
final class PhabricatorMailManagementListInboundWorkflow
extends PhabricatorSearchManagementWorkflow {
protected function didConstruct() {
$this
->setName('list-inbound')
->setSynopsis('List inbound messages received by Phabricator.')
->setExamples(
"**list-inbound**")
->setArguments(
array(
array(
'name' => 'limit',
'param' => 'N',
'default' => 100,
'help' => 'Show a specific number of messages (default 100).',
),
));
}
public function execute(PhutilArgumentParser $args) {
$console = PhutilConsole::getConsole();
$viewer = PhabricatorUser::getOmnipotentUser();
$mails = id(new PhabricatorMetaMTAReceivedMail())->loadAllWhere(
'1 = 1 ORDER BY id DESC LIMIT %d',
$args->getArg('limit'));
if (!$mails) {
$console->writeErr("%s\n", "No received mail.");
return 0;
}
$phids = array_merge(
mpull($mails, 'getRelatedPHID'),
mpull($mails, 'getAuthorPHID'));
$handles = id(new PhabricatorObjectHandleData($phids))
->setViewer($viewer)
->loadHandles();
foreach (array_reverse($mails) as $mail) {
$console->writeOut(
"%s\n",
sprintf(
"% 8d %-16s %-20s %s",
$mail->getID(),
$mail->getAuthorPHID()
? $handles[$mail->getAuthorPHID()]->getName()
: '-',
$mail->getRelatedPHID()
? $handles[$mail->getRelatedPHID()]->getName()
: '-',
$mail->getSubject()
? $mail->getSubject()
: pht('(No subject.)')));
}
return 0;
}
}