3 final class PhabricatorAphlictManagementNotifyWorkflow
4 extends PhabricatorAphlictManagementWorkflow
{
6 protected function didConstruct() {
9 ->setSynopsis(pht('Send a notification to a user.'))
14 'param' => 'username',
15 'help' => pht('User to notify.'),
20 'help' => pht('Message to send.'),
25 public function execute(PhutilArgumentParser
$args) {
26 $viewer = $this->getViewer();
28 $username = $args->getArg('user');
29 if (!strlen($username)) {
30 throw new PhutilArgumentUsageException(
32 'Specify a user to notify with "--user".'));
35 $user = id(new PhabricatorPeopleQuery())
37 ->withUsernames(array($username))
41 throw new PhutilArgumentUsageException(
43 'No user with username "%s" exists.',
47 $message = $args->getArg('message');
48 if (!strlen($message)) {
49 throw new PhutilArgumentUsageException(
51 'Specify a message to send with "--message".'));
54 $application_phid = id(new PhabricatorNotificationsApplication())
57 $content_source = $this->newContentSource();
61 $xactions[] = id(new PhabricatorUserTransaction())
63 PhabricatorUserNotifyTransaction
::TRANSACTIONTYPE
)
64 ->setNewValue($message)
65 ->setForceNotifyPHIDs(array($user->getPHID()));
67 $editor = id(new PhabricatorUserTransactionEditor())
69 ->setActingAsPHID($application_phid)
70 ->setContentSource($content_source);
72 $editor->applyTransactions($user, $xactions);
76 pht('Sent notification.'));