@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a "Send Test Notification" button to make testing the server easier

Summary: Ref T4324. Currently, it's a bit of a pain to send yourself notifications, and often involves multiple browsers. Instead, add a button to send them.

Test Plan: {F114495}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4324

Differential Revision: https://secure.phabricator.com/D8255

+104 -5
+4
src/__phutil_library_map__.php
··· 1697 1697 'PhabricatorNamedQuery' => 'applications/search/storage/PhabricatorNamedQuery.php', 1698 1698 'PhabricatorNamedQueryQuery' => 'applications/search/query/PhabricatorNamedQueryQuery.php', 1699 1699 'PhabricatorNoteExample' => 'applications/uiexample/examples/PhabricatorNoteExample.php', 1700 + 'PhabricatorNotificationAdHocFeedStory' => 'applications/notification/feed/PhabricatorNotificationAdHocFeedStory.php', 1700 1701 'PhabricatorNotificationBuilder' => 'applications/notification/builder/PhabricatorNotificationBuilder.php', 1701 1702 'PhabricatorNotificationClearController' => 'applications/notification/controller/PhabricatorNotificationClearController.php', 1702 1703 'PhabricatorNotificationClient' => 'applications/notification/client/PhabricatorNotificationClient.php', ··· 1707 1708 'PhabricatorNotificationPanelController' => 'applications/notification/controller/PhabricatorNotificationPanelController.php', 1708 1709 'PhabricatorNotificationQuery' => 'applications/notification/PhabricatorNotificationQuery.php', 1709 1710 'PhabricatorNotificationStatusController' => 'applications/notification/controller/PhabricatorNotificationStatusController.php', 1711 + 'PhabricatorNotificationTestController' => 'applications/notification/controller/PhabricatorNotificationTestController.php', 1710 1712 'PhabricatorOAuthClientAuthorization' => 'applications/oauthserver/storage/PhabricatorOAuthClientAuthorization.php', 1711 1713 'PhabricatorOAuthClientAuthorizationBaseController' => 'applications/oauthserver/controller/clientauthorization/PhabricatorOAuthClientAuthorizationBaseController.php', 1712 1714 'PhabricatorOAuthClientAuthorizationDeleteController' => 'applications/oauthserver/controller/clientauthorization/PhabricatorOAuthClientAuthorizationDeleteController.php', ··· 4430 4432 ), 4431 4433 'PhabricatorNamedQueryQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 4432 4434 'PhabricatorNoteExample' => 'PhabricatorUIExample', 4435 + 'PhabricatorNotificationAdHocFeedStory' => 'PhabricatorFeedStory', 4433 4436 'PhabricatorNotificationClearController' => 'PhabricatorNotificationController', 4434 4437 'PhabricatorNotificationConfigOptions' => 'PhabricatorApplicationConfigOptions', 4435 4438 'PhabricatorNotificationController' => 'PhabricatorController', ··· 4438 4441 'PhabricatorNotificationPanelController' => 'PhabricatorNotificationController', 4439 4442 'PhabricatorNotificationQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 4440 4443 'PhabricatorNotificationStatusController' => 'PhabricatorNotificationController', 4444 + 'PhabricatorNotificationTestController' => 'PhabricatorNotificationController', 4441 4445 'PhabricatorOAuthClientAuthorization' => 'PhabricatorOAuthServerDAO', 4442 4446 'PhabricatorOAuthClientAuthorizationBaseController' => 'PhabricatorOAuthServerController', 4443 4447 'PhabricatorOAuthClientAuthorizationDeleteController' => 'PhabricatorOAuthClientAuthorizationBaseController',
+17 -3
src/applications/feed/PhabricatorFeedStoryPublisher.php
··· 10 10 private $primaryObjectPHID; 11 11 private $subscribedPHIDs = array(); 12 12 private $mailRecipientPHIDs = array(); 13 + private $notifyAuthor; 14 + 15 + 16 + public function setNotifyAuthor($notify_author) { 17 + $this->notifyAuthor = $notify_author; 18 + return $this; 19 + } 20 + 21 + public function getNotifyAuthor() { 22 + return $this->notifyAuthor; 23 + } 13 24 14 25 public function setRelatedPHIDs(array $phids) { 15 26 $this->relatedPHIDs = $phids; ··· 116 127 117 128 private function insertNotifications($chrono_key) { 118 129 $subscribed_phids = $this->subscribedPHIDs; 119 - $subscribed_phids = array_diff( 120 - $subscribed_phids, 121 - array($this->storyAuthorPHID)); 130 + 131 + if (!$this->notifyAuthor) { 132 + $subscribed_phids = array_diff( 133 + $subscribed_phids, 134 + array($this->storyAuthorPHID)); 135 + } 122 136 123 137 if (!$subscribed_phids) { 124 138 return;
+1
src/applications/notification/application/PhabricatorApplicationNotifications.php
··· 19 19 'individual/' => 'PhabricatorNotificationIndividualController', 20 20 'status/' => 'PhabricatorNotificationStatusController', 21 21 'clear/' => 'PhabricatorNotificationClearController', 22 + 'test/' => 'PhabricatorNotificationTestController', 22 23 ), 23 24 ); 24 25 }
+1 -1
src/applications/notification/controller/PhabricatorNotificationIndividualController.php
··· 26 26 $response = array( 27 27 'pertinent' => true, 28 28 'primaryObjectPHID' => head($stories)->getPrimaryObjectPHID(), 29 - 'content' => $content, 29 + 'content' => hsprintf('%s', $content), 30 30 ); 31 31 32 32 return id(new AphrontAjaxResponse())->setContent($response);
+16 -1
src/applications/notification/controller/PhabricatorNotificationStatusController.php
··· 59 59 'wide', 60 60 )); 61 61 62 + $test_icon = id(new PHUIIconView()) 63 + ->setSpriteSheet(PHUIIconView::SPRITE_ICONS) 64 + ->setSpriteIcon('warning'); 65 + 66 + $test_button = id(new PHUIButtonView()) 67 + ->setTag('a') 68 + ->setWorkflow(true) 69 + ->setText(pht('Send Test Notification')) 70 + ->setHref($this->getApplicationURI("test/")) 71 + ->setIcon($test_icon); 72 + 73 + $header = id(new PHUIHeaderView()) 74 + ->setHeader(pht('Notification Server Status')) 75 + ->addActionLink($test_button); 76 + 62 77 $box = id(new PHUIObjectBoxView()) 63 - ->setHeaderText(pht('Server Status')) 78 + ->setHeader($header) 64 79 ->appendChild($table); 65 80 66 81 return $box;
+38
src/applications/notification/controller/PhabricatorNotificationTestController.php
··· 1 + <?php 2 + 3 + final class PhabricatorNotificationTestController 4 + extends PhabricatorNotificationController { 5 + 6 + public function processRequest() { 7 + $request = $this->getRequest(); 8 + $viewer = $request->getUser(); 9 + 10 + $story_type = 'PhabricatorNotificationAdHocFeedStory'; 11 + $story_data = array( 12 + 'title' => pht( 13 + 'This is a test notification, sent at %s.', 14 + phabricator_datetime(time(), $viewer)), 15 + ); 16 + 17 + $viewer_phid = $viewer->getPHID(); 18 + 19 + // TODO: When it's easier to get these buttons to render as forms, this 20 + // would be slightly nicer as a more standard isFormPost() check. 21 + 22 + if ($request->validateCSRF()) { 23 + id(new PhabricatorFeedStoryPublisher()) 24 + ->setStoryType($story_type) 25 + ->setStoryData($story_data) 26 + ->setStoryTime(time()) 27 + ->setStoryAuthorPHID($viewer_phid) 28 + ->setRelatedPHIDs(array($viewer_phid)) 29 + ->setPrimaryObjectPHID($viewer_phid) 30 + ->setSubscribedPHIDs(array($viewer_phid)) 31 + ->setNotifyAuthor(true) 32 + ->publish(); 33 + } 34 + 35 + return id(new AphrontAjaxResponse()); 36 + } 37 + 38 + }
+27
src/applications/notification/feed/PhabricatorNotificationAdHocFeedStory.php
··· 1 + <?php 2 + 3 + final class PhabricatorNotificationAdHocFeedStory extends PhabricatorFeedStory { 4 + 5 + public function getPrimaryObjectPHID() { 6 + return $this->getAuthorPHID(); 7 + } 8 + 9 + public function renderView() { 10 + $data = $this->getStoryData(); 11 + 12 + $author_phid = $data->getAuthorPHID(); 13 + 14 + $view = $this->newStoryView(); 15 + 16 + $view->setTitle($data->getValue('title')); 17 + $view->setImage($this->getHandle($author_phid)->getImageURI()); 18 + 19 + return $view; 20 + } 21 + 22 + public function renderText() { 23 + $data = $this->getStoryData(); 24 + return $data->getValue('title'); 25 + } 26 + 27 + }