Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / metamta / management / PhabricatorMailManagementResendWorkflow.php
blob1eb843a82a066d92f32f641e9a7497b08e8c79a6
1 <?php
3 final class PhabricatorMailManagementResendWorkflow
4 extends PhabricatorMailManagementWorkflow {
6 protected function didConstruct() {
7 $this
8 ->setName('resend')
9 ->setSynopsis(pht('Send mail again.'))
10 ->setExamples(
11 '**resend** --id 1 --id 2')
12 ->setArguments(
13 array(
14 array(
15 'name' => 'id',
16 'param' => 'id',
17 'help' => pht('Send mail with a given ID again.'),
18 'repeat' => true,
20 ));
23 public function execute(PhutilArgumentParser $args) {
24 $console = PhutilConsole::getConsole();
26 $ids = $args->getArg('id');
27 if (!$ids) {
28 throw new PhutilArgumentUsageException(
29 pht(
30 "Use the '%s' flag to specify one or more messages to resend.",
31 '--id'));
34 $messages = id(new PhabricatorMetaMTAMail())->loadAllWhere(
35 'id IN (%Ld)',
36 $ids);
38 if ($ids) {
39 $ids = array_fuse($ids);
40 $missing = array_diff_key($ids, $messages);
41 if ($missing) {
42 throw new PhutilArgumentUsageException(
43 pht(
44 'Some specified messages do not exist: %s',
45 implode(', ', array_keys($missing))));
49 foreach ($messages as $message) {
50 $message->setStatus(PhabricatorMailOutboundStatus::STATUS_QUEUE);
51 $message->save();
53 $mailer_task = PhabricatorWorker::scheduleTask(
54 'PhabricatorMetaMTAWorker',
55 $message->getID(),
56 array(
57 'priority' => PhabricatorWorker::PRIORITY_ALERTS,
58 ));
60 $console->writeOut(
61 "%s\n",
62 pht(
63 'Queued message #%d for resend.',
64 $message->getID()));