@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final 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}