mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-31 08:58:20 +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:
parent
8789f97867
commit
a5f6e19dfd
1 changed files with 19 additions and 3 deletions
|
@ -11,14 +11,16 @@ final class PhabricatorBotFeedNotificationHandler
|
|||
private $startupDelay = 30;
|
||||
private $lastSeenChronoKey = 0;
|
||||
|
||||
private $typesNeedURI = array('DREV', 'TASK');
|
||||
|
||||
private function shouldShowStory($story) {
|
||||
$story_class = $story['class'];
|
||||
$story_objectphid = $story['objectPHID'];
|
||||
$story_text = $story['text'];
|
||||
|
||||
$show = $this->getConfig('notification.types');
|
||||
|
||||
if ($show) {
|
||||
$obj_type = str_replace('PhabricatorFeedStory', '', $story_class);
|
||||
$obj_type = phid_get_type($story_objectphid);
|
||||
if (!in_array(strtolower($obj_type), $show)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -62,6 +64,8 @@ final class PhabricatorBotFeedNotificationHandler
|
|||
'closed',
|
||||
'raised',
|
||||
'committed',
|
||||
'abandoned',
|
||||
'reclaimed',
|
||||
'reopened',
|
||||
'deleted'
|
||||
);
|
||||
|
@ -148,6 +152,18 @@ final class PhabricatorBotFeedNotificationHandler
|
|||
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');
|
||||
foreach ($channels as $channel_name) {
|
||||
|
||||
|
@ -158,7 +174,7 @@ final class PhabricatorBotFeedNotificationHandler
|
|||
id(new PhabricatorBotMessage())
|
||||
->setCommand('MESSAGE')
|
||||
->setTarget($channel)
|
||||
->setBody($story['text']));
|
||||
->setBody($message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue