Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / notification / controller / PhabricatorNotificationTestController.php
blobf49f9d31a166bbfa08dba0be5cdf2ce21cb8a101
1 <?php
3 final class PhabricatorNotificationTestController
4 extends PhabricatorNotificationController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $request->getViewer();
9 if ($request->validateCSRF()) {
10 $message_text = pht(
11 'This is a test notification, sent at %s.',
12 phabricator_datetime(time(), $viewer));
14 // NOTE: Currently, the FeedStoryPublisher explicitly filters out
15 // notifications about your own actions. Send this notification from
16 // a different actor to get around this.
17 $application_phid = id(new PhabricatorNotificationsApplication())
18 ->getPHID();
20 $xactions = array();
22 $xactions[] = id(new PhabricatorUserTransaction())
23 ->setTransactionType(
24 PhabricatorUserNotifyTransaction::TRANSACTIONTYPE)
25 ->setNewValue($message_text)
26 ->setForceNotifyPHIDs(array($viewer->getPHID()));
28 $editor = id(new PhabricatorUserTransactionEditor())
29 ->setActor($viewer)
30 ->setActingAsPHID($application_phid)
31 ->setContentSourceFromRequest($request);
33 $editor->applyTransactions($viewer, $xactions);
36 return id(new AphrontAjaxResponse());