Differential D11143 Diff 27109 src/applications/notification/controller/PhabricatorNotificationTestController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/notification/controller/PhabricatorNotificationTestController.php
Show All 10 Lines | public function processRequest() { | ||||
$story_data = array( | $story_data = array( | ||||
'title' => pht( | 'title' => pht( | ||||
'This is a test notification, sent at %s.', | 'This is a test notification, sent at %s.', | ||||
phabricator_datetime(time(), $viewer)), | phabricator_datetime(time(), $viewer)), | ||||
); | ); | ||||
$viewer_phid = $viewer->getPHID(); | $viewer_phid = $viewer->getPHID(); | ||||
// NOTE: Because we don't currently show you your own notifications, make | |||||
// sure this comes from a different PHID. | |||||
$application_phid = id(new PhabricatorNotificationsApplication()) | |||||
->getPHID(); | |||||
// TODO: When it's easier to get these buttons to render as forms, this | // TODO: When it's easier to get these buttons to render as forms, this | ||||
// would be slightly nicer as a more standard isFormPost() check. | // would be slightly nicer as a more standard isFormPost() check. | ||||
if ($request->validateCSRF()) { | if ($request->validateCSRF()) { | ||||
id(new PhabricatorFeedStoryPublisher()) | id(new PhabricatorFeedStoryPublisher()) | ||||
->setStoryType($story_type) | ->setStoryType($story_type) | ||||
->setStoryData($story_data) | ->setStoryData($story_data) | ||||
->setStoryTime(time()) | ->setStoryTime(time()) | ||||
->setStoryAuthorPHID($viewer_phid) | ->setStoryAuthorPHID($application_phid) | ||||
->setRelatedPHIDs(array($viewer_phid)) | ->setRelatedPHIDs(array($viewer_phid)) | ||||
->setPrimaryObjectPHID($viewer_phid) | ->setPrimaryObjectPHID($viewer_phid) | ||||
->setSubscribedPHIDs(array($viewer_phid)) | ->setSubscribedPHIDs(array($viewer_phid)) | ||||
->setNotifyAuthor(true) | ->setNotifyAuthor(true) | ||||
->publish(); | ->publish(); | ||||
} | } | ||||
return id(new AphrontAjaxResponse()); | return id(new AphrontAjaxResponse()); | ||||
} | } | ||||
} | } |