Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/notification/controller/PhabricatorNotificationTestController.php
12256 views
1
<?php
2
3
final class PhabricatorNotificationTestController
4
extends PhabricatorNotificationController {
5
6
public function handleRequest(AphrontRequest $request) {
7
$viewer = $request->getViewer();
8
9
if ($request->validateCSRF()) {
10
$message_text = pht(
11
'This is a test notification, sent at %s.',
12
phabricator_datetime(time(), $viewer));
13
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();
19
20
$xactions = array();
21
22
$xactions[] = id(new PhabricatorUserTransaction())
23
->setTransactionType(
24
PhabricatorUserNotifyTransaction::TRANSACTIONTYPE)
25
->setNewValue($message_text)
26
->setForceNotifyPHIDs(array($viewer->getPHID()));
27
28
$editor = id(new PhabricatorUserTransactionEditor())
29
->setActor($viewer)
30
->setActingAsPHID($application_phid)
31
->setContentSourceFromRequest($request);
32
33
$editor->applyTransactions($viewer, $xactions);
34
}
35
36
return id(new AphrontAjaxResponse());
37
}
38
39
}
40
41