Path: blob/master/src/applications/notification/controller/PhabricatorNotificationTestController.php
12256 views
<?php12final class PhabricatorNotificationTestController3extends PhabricatorNotificationController {45public function handleRequest(AphrontRequest $request) {6$viewer = $request->getViewer();78if ($request->validateCSRF()) {9$message_text = pht(10'This is a test notification, sent at %s.',11phabricator_datetime(time(), $viewer));1213// NOTE: Currently, the FeedStoryPublisher explicitly filters out14// notifications about your own actions. Send this notification from15// a different actor to get around this.16$application_phid = id(new PhabricatorNotificationsApplication())17->getPHID();1819$xactions = array();2021$xactions[] = id(new PhabricatorUserTransaction())22->setTransactionType(23PhabricatorUserNotifyTransaction::TRANSACTIONTYPE)24->setNewValue($message_text)25->setForceNotifyPHIDs(array($viewer->getPHID()));2627$editor = id(new PhabricatorUserTransactionEditor())28->setActor($viewer)29->setActingAsPHID($application_phid)30->setContentSourceFromRequest($request);3132$editor->applyTransactions($viewer, $xactions);33}3435return id(new AphrontAjaxResponse());36}3738}394041