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

Fix some bot issues

Summary:
- Deprecate differentialnotification in favor of feednotification; it's strictly better.
- Fix feed notification + channels.
- Fix rendering of new-style stories (pholio, macro), which currently fatal.

Test Plan: See chatlog.

Reviewers: codeblock, indiefan

Reviewed By: codeblock

CC: aran

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

+18 -46
+5
src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php
··· 48 48 return $view; 49 49 } 50 50 51 + public function renderText() { 52 + // TODO: This is grotesque; the feed notification handler relies on it. 53 + return strip_tags($this->renderView()->render()); 54 + } 55 + 51 56 }
+8 -45
src/infrastructure/daemon/bot/handler/PhabricatorBotDifferentialNotificationHandler.php
··· 1 1 <?php 2 2 3 3 /** 4 - * @group irc 4 + * @deprecated 5 5 */ 6 6 final class PhabricatorBotDifferentialNotificationHandler 7 - extends PhabricatorBotHandler { 8 - 9 - private $skippedOldEvents; 7 + extends PhabricatorBotHandler { 10 8 11 9 public function receiveMessage(PhabricatorBotMessage $message) { 12 - return; 13 - } 14 - 15 - public function runBackgroundTasks() { 16 - $iterator = new PhabricatorTimelineIterator('ircdiffx', array('difx')); 17 - $show = $this->getConfig('notification.actions'); 18 - 19 - if (!$this->skippedOldEvents) { 20 - // Since we only want to post notifications about new events, skip 21 - // everything that's happened in the past when we start up so we'll 22 - // only process real-time events. 23 - foreach ($iterator as $event) { 24 - // Ignore all old events. 25 - } 26 - $this->skippedOldEvents = true; 27 - return; 28 - } 29 - 30 - foreach ($iterator as $event) { 31 - $data = $event->getData(); 32 - if (!$data || ($show !== null && !in_array($data['action'], $show))) { 33 - continue; 34 - } 35 - 36 - $actor_phid = $data['actor_phid']; 37 - $phids = array($actor_phid); 38 - $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); 39 - $verb = DifferentialAction::getActionPastTenseVerb($data['action']); 40 - 41 - $actor_name = $handles[$actor_phid]->getName(); 42 - $message_body = 43 - "{$actor_name} {$verb} revision D".$data['revision_id']."."; 44 - 45 - $channels = $this->getConfig('notification.channels', array()); 46 - foreach ($channels as $channel) { 47 - $this->writeMessage( 48 - id(new PhabricatorBotMessage()) 49 - ->setCommand('MESSAGE') 50 - ->setTarget($channel) 51 - ->setBody($message_body)); 52 - } 10 + static $notified; 11 + if (!$notified) { 12 + phlog( 13 + 'PhabricatorBotDifferentialNotificationHandler is deprecated, use '. 14 + 'PhabricatorBotFeedNotificationHandler instead.'); 15 + $notified = true; 53 16 } 54 17 } 55 18
+5 -1
src/infrastructure/daemon/bot/handler/PhabricatorBotFeedNotificationHandler.php
··· 149 149 } 150 150 151 151 $channels = $this->getConfig('join'); 152 - foreach ($channels as $channel) { 152 + foreach ($channels as $channel_name) { 153 + 154 + $channel = id(new PhabricatorBotChannel()) 155 + ->setName($channel_name); 156 + 153 157 $this->writeMessage( 154 158 id(new PhabricatorBotMessage()) 155 159 ->setCommand('MESSAGE')