1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-07 12:28:28 +01:00

Make PhabricatorBotFeedNotificationHandler work with new PhabricatorApplicationTransactionFeedStory

Summary: Depends on D8521

Test Plan: ran with handler enabled and phabot posted stories

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: aran, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8524
This commit is contained in:
John Watson 2014-03-13 18:20:05 -07:00 committed by epriestley
parent 8789f97867
commit a5f6e19dfd

View file

@ -11,14 +11,16 @@ final class PhabricatorBotFeedNotificationHandler
private $startupDelay = 30; private $startupDelay = 30;
private $lastSeenChronoKey = 0; private $lastSeenChronoKey = 0;
private $typesNeedURI = array('DREV', 'TASK');
private function shouldShowStory($story) { private function shouldShowStory($story) {
$story_class = $story['class']; $story_objectphid = $story['objectPHID'];
$story_text = $story['text']; $story_text = $story['text'];
$show = $this->getConfig('notification.types'); $show = $this->getConfig('notification.types');
if ($show) { if ($show) {
$obj_type = str_replace('PhabricatorFeedStory', '', $story_class); $obj_type = phid_get_type($story_objectphid);
if (!in_array(strtolower($obj_type), $show)) { if (!in_array(strtolower($obj_type), $show)) {
return false; return false;
} }
@ -62,6 +64,8 @@ final class PhabricatorBotFeedNotificationHandler
'closed', 'closed',
'raised', 'raised',
'committed', 'committed',
'abandoned',
'reclaimed',
'reopened', 'reopened',
'deleted' 'deleted'
); );
@ -148,6 +152,18 @@ final class PhabricatorBotFeedNotificationHandler
continue; continue;
} }
$message = $story['text'];
$story_object_type = phid_get_type($story['objectPHID']);
if (in_array($story_object_type, $this->typesNeedURI)) {
$objects = $this->getConduit()->callMethodSynchronous(
'phid.lookup',
array(
'names' => array($story['objectPHID']),
));
$message .= ' '.$objects[$story['objectPHID']]['uri'];
}
$channels = $this->getConfig('join'); $channels = $this->getConfig('join');
foreach ($channels as $channel_name) { foreach ($channels as $channel_name) {
@ -158,7 +174,7 @@ final class PhabricatorBotFeedNotificationHandler
id(new PhabricatorBotMessage()) id(new PhabricatorBotMessage())
->setCommand('MESSAGE') ->setCommand('MESSAGE')
->setTarget($channel) ->setTarget($channel)
->setBody($story['text'])); ->setBody($message));
} }
} }
} }