Page MenuHomePhabricator
Paste P1839

PhabricatorBotFeedNotificationHandler dirty patch to support filtering by projects
ActivePublic

Authored by srijan on Aug 5 2015, 6:21 PM.
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())

Event Timeline

srijan changed the title of this paste from untitled to PhabricatorBotFeedNotificationHandler dirty patch to support filtering by projects.
srijan updated the paste's language from autodetect to diff.
srijan changed the edit policy from "All Users" to "srijan (Srijan Choudhary)".