Page MenuHomePhabricator

PhabricatorBotFeedNotificationHandler dirty patch to support filtering by projects

Authored By
srijan
Aug 5 2015, 6:21 PM
Size
2 KB
Referenced Files
None
Subscribers
None

PhabricatorBotFeedNotificationHandler dirty patch to support filtering by projects

diff --git a/src/infrastructure/daemon/bot/handler/PhabricatorBotFeedNotificationHandler.php b/src/infrastructure/daemon/bot/handler/PhabricatorBotFeedNotificationHandler.php
index 21eadf1..a058789 100644
--- a/src/infrastructure/daemon/bot/handler/PhabricatorBotFeedNotificationHandler.php
+++ b/src/infrastructure/daemon/bot/handler/PhabricatorBotFeedNotificationHandler.php
@@ -17,12 +17,31 @@ final class PhabricatorBotFeedNotificationHandler
$show = $this->getConfig('notification.types');
+ $projects = $this->getConfig('notification.projects');
+
+ $obj_type = phid_get_type($story_objectphid);
if ($show) {
- $obj_type = phid_get_type($story_objectphid);
if (!in_array(strtolower($obj_type), $show)) {
return false;
}
}
+ if ($projects) {
+ if ($obj_type == 'TASK') {
+ $api_parameters = array(
+ 'phids' => array(
+ $story_objectphid
+ ),
+ 'projectPHIDs' => $projects
+ );
+ $objects = $this->getConduit()->callMethodSynchronous(
+ 'maniphest.query',
+ $api_parameters
+ );
+ if(empty($objects)) {
+ return false;
+ }
+ }
+ }
$verbosity = $this->getConfig('notification.verbosity', 3);
@@ -125,12 +144,12 @@ final class PhabricatorBotFeedNotificationHandler
'feed.query',
array(
'limit' => $config_page_size,
- 'after' => $chrono_key_cursor,
+ 'before' => $chrono_key_cursor,
'view' => 'text',
));
foreach ($stories as $story) {
- if ($story['chronologicalKey'] == $last_seen_chrono_key) {
+ if ($story['chronologicalKey'] <= $last_seen_chrono_key) {
// Caught up on feed
return;
}
@@ -161,7 +180,7 @@ final class PhabricatorBotFeedNotificationHandler
$message .= ' '.$objects[$story['objectPHID']]['uri'];
}
- $channels = $this->getConfig('join');
+ $channels = $this->getConfig('notification.channels');
foreach ($channels as $channel_name) {
$channel = id(new PhabricatorBotChannel())

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/ms/hc/uadibrn2ex7yu3yc
Default Alt Text
PhabricatorBotFeedNotificationHandler dirty patch to support filtering by projects (2 KB)

Event Timeline