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

Separate "feed" and "notifications" better, allow stories to appear in notifications only

Summary:
Depends on D19861. Ref T13222. See PHI996. Fixes T10743. Currently, notifications only work if a story also has a feed rendering.

Separate "visible in feed" and "visible in notifications", and make notifications query only notifications and vice versa.

Then, set the test notification stories to be visible in notifications only, not feed.

This could be refined a bit (there's no way to have the two views render different values today, for example) but since the only actual use case we have right now is test notifications I don't want to go //too// crazy future-proofing it. I could imagine doing some more of this kind of stuff in Conpherence eventually, though, perhaps.

Test Plan: Sent myself test notifications, saw them appear on my profile timeline and in the JS popup, and in my notifications menu, but not in feed.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13222, T10743

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

+107 -16
+9 -1
src/applications/feed/query/PhabricatorFeedQuery.php
··· 34 34 } 35 35 36 36 protected function willFilterPage(array $data) { 37 - return PhabricatorFeedStory::loadAllFromRows($data, $this->getViewer()); 37 + $stories = PhabricatorFeedStory::loadAllFromRows($data, $this->getViewer()); 38 + 39 + foreach ($stories as $key => $story) { 40 + if (!$story->isVisibleInFeed()) { 41 + unset($stories[$key]); 42 + } 43 + } 44 + 45 + return $stories; 38 46 } 39 47 40 48 protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) {
+8
src/applications/feed/story/PhabricatorFeedStory.php
··· 418 418 return array(); 419 419 } 420 420 421 + public function isVisibleInFeed() { 422 + return true; 423 + } 424 + 425 + public function isVisibleInNotifications() { 426 + return true; 427 + } 428 + 421 429 422 430 /* -( PhabricatorPolicyInterface Implementation )-------------------------- */ 423 431
+15 -5
src/applications/notification/query/PhabricatorNotificationQuery.php
··· 53 53 54 54 $data = queryfx_all( 55 55 $conn, 56 - 'SELECT story.*, notif.hasViewed FROM %T notif 57 - JOIN %T story ON notif.chronologicalKey = story.chronologicalKey 56 + 'SELECT story.*, notif.hasViewed FROM %R notif 57 + JOIN %R story ON notif.chronologicalKey = story.chronologicalKey 58 58 %Q 59 59 ORDER BY notif.chronologicalKey DESC 60 60 %Q', 61 - $notification_table->getTableName(), 62 - $story_table->getTableName(), 61 + $notification_table, 62 + $story_table, 63 63 $this->buildWhereClause($conn), 64 64 $this->buildLimitClause($conn)); 65 65 ··· 93 93 (int)!$this->unread); 94 94 } 95 95 96 - if ($this->keys) { 96 + if ($this->keys !== null) { 97 97 $where[] = qsprintf( 98 98 $conn, 99 99 'notif.chronologicalKey IN (%Ls)', ··· 101 101 } 102 102 103 103 return $where; 104 + } 105 + 106 + protected function willFilterPage(array $stories) { 107 + foreach ($stories as $key => $story) { 108 + if (!$story->isVisibleInNotifications()) { 109 + unset($stories[$key]); 110 + } 111 + } 112 + 113 + return $stories; 104 114 } 105 115 106 116 protected function getResultCursor($item) {
+5 -1
src/applications/people/xaction/PhabricatorUserNotifyTransaction.php
··· 23 23 return $this->getNewValue(); 24 24 } 25 25 26 - public function shouldHideForFeed() { 26 + public function shouldHideForNotifications() { 27 27 return false; 28 + } 29 + 30 + public function shouldHideForFeed() { 31 + return true; 28 32 } 29 33 30 34 public function shouldHideForMail() {
+1 -1
src/applications/settings/panel/PhabricatorNotificationsSettingsPanel.php
··· 143 143 ->setCaption( 144 144 pht( 145 145 'Phabricator can send real-time notifications to your web browser '. 146 - 'or to your desktop. Select where you\'d want to receive these '. 146 + 'or to your desktop. Select where you want to receive these '. 147 147 'real-time updates.')) 148 148 ->initBehavior( 149 149 'desktop-notifications-control',
+13 -1
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 3428 3428 array $xactions, 3429 3429 array $mailed_phids) { 3430 3430 3431 - $xactions = mfilter($xactions, 'shouldHideForFeed', true); 3431 + // Remove transactions which don't publish feed stories or notifications. 3432 + // These never show up anywhere, so we don't need to do anything with them. 3433 + foreach ($xactions as $key => $xaction) { 3434 + if (!$xaction->shouldHideForFeed()) { 3435 + continue; 3436 + } 3437 + 3438 + if (!$xaction->shouldHideForNotifications()) { 3439 + continue; 3440 + } 3441 + 3442 + unset($xactions[$key]); 3443 + } 3432 3444 3433 3445 if (!$xactions) { 3434 3446 return;
+37 -7
src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php
··· 36 36 // time because it's cheap and gets us better results when things change 37 37 // by letting the changes apply retroactively. 38 38 39 - $xaction_phids = $this->getValue('transactionPHIDs'); 40 - 41 - $xactions = array(); 42 - foreach ($xaction_phids as $xaction_phid) { 43 - $xactions[] = $this->getObject($xaction_phid); 44 - } 39 + $xactions = $this->getTransactions(); 45 40 46 41 foreach ($xactions as $key => $xaction) { 47 42 if ($xaction->shouldHideForFeed()) { ··· 52 47 if ($xactions) { 53 48 $primary_phid = head($xactions)->getPHID(); 54 49 } else { 55 - $primary_phid = head($xaction_phids); 50 + $primary_phid = head($this->getValue('transactionPHIDs')); 56 51 } 57 52 58 53 $this->primaryTransactionPHID = $primary_phid; 59 54 } 60 55 61 56 return $this->primaryTransactionPHID; 57 + } 58 + 59 + public function isVisibleInNotifications() { 60 + $xactions = $this->getTransactions(); 61 + 62 + foreach ($xactions as $key => $xaction) { 63 + if (!$xaction->shouldHideForNotifications()) { 64 + return true; 65 + } 66 + } 67 + 68 + return false; 69 + } 70 + 71 + public function isVisibleInFeed() { 72 + $xactions = $this->getTransactions(); 73 + 74 + foreach ($xactions as $key => $xaction) { 75 + if (!$xaction->shouldHideForFeed()) { 76 + return true; 77 + } 78 + } 79 + 80 + return false; 81 + } 82 + 83 + private function getTransactions() { 84 + $xaction_phids = $this->getValue('transactionPHIDs'); 85 + 86 + $xactions = array(); 87 + foreach ($xaction_phids as $xaction_phid) { 88 + $xactions[] = $this->getObject($xaction_phid); 89 + } 90 + 91 + return $xactions; 62 92 } 63 93 64 94 public function getPrimaryTransaction() {
+4
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 759 759 return $this->shouldHide(); 760 760 } 761 761 762 + public function shouldHideForNotifications() { 763 + return $this->shouldHideForFeed(); 764 + } 765 + 762 766 public function getTitleForMail() { 763 767 return id(clone $this)->setRenderingTarget('text')->getTitle(); 764 768 }
+11
src/applications/transactions/storage/PhabricatorModularTransaction.php
··· 108 108 return parent::shouldHideForMail($xactions); 109 109 } 110 110 111 + final public function shouldHideForNotifications() { 112 + $hide = $this->getTransactionImplementation()->shouldHideForNotifications(); 113 + 114 + // Returning "null" means "use the default behavior". 115 + if ($hide === null) { 116 + return parent::shouldHideForNotifications(); 117 + } 118 + 119 + return $hide; 120 + } 121 + 111 122 /* final */ public function getIcon() { 112 123 $icon = $this->getTransactionImplementation()->getIcon(); 113 124 if ($icon !== null) {
+4
src/applications/transactions/storage/PhabricatorModularTransactionType.php
··· 59 59 return false; 60 60 } 61 61 62 + public function shouldHideForNotifications() { 63 + return null; 64 + } 65 + 62 66 public function getIcon() { 63 67 return null; 64 68 }